Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tooltip positioning near edge [FC-0062] #35848

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cms/static/js/views/pages/container_subviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,13 @@ function($, _, gettext, BaseView, ViewUtils, XBlockViewUtils, MoveXBlockUtils, H
},

renderTagElements: function(tags, depth, parentId) {
/* This function updates the tags in the sidebar of the legacy Unit Outline Page.
* It is not used in the mfe version of the Unit Outline. */
const parentElement = document.querySelector(`.content-tags-${parentId}`);
if (!parentElement) return;

const tagListElement = this;
tags.forEach(function(tag) {
const parentElement = document.querySelector(`.content-tags-${parentId}`);
var tagContentElement = document.createElement('div'),
tagValueElement = document.createElement('span');

Expand Down
15 changes: 13 additions & 2 deletions common/static/js/src/tooltip_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,20 @@
},

getCoords: function(pageX, pageY) {
let left = pageX - 0.5 * this.tooltip.outerWidth();
const top = pageY - (this.tooltip.outerHeight() + 15);
// Check if the tooltip is going off the right edge of the screen
if (left + this.tooltip.outerWidth() > window.innerWidth) {
left = window.innerWidth - this.tooltip.outerWidth();
}
// Check if the tooltip is going off the left edge of the screen
if (left < 0) {
left = 0;
}

return {
left: pageX - 0.5 * this.tooltip.outerWidth(),
top: pageY - (this.tooltip.outerHeight() + 15)
left,
top,
};
},

Expand Down
Loading