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

Bugfix for FeatherGridContextMenu placement in cases where body height < document height (i.e. no page scrollbar) #443

Closed
wants to merge 18 commits into from
Closed
Changes from all 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
11 changes: 9 additions & 2 deletions js/core/gridContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ export class FeatherGridContextMenu extends GridContextMenu {
const py = window.pageYOffset;
const cw = document.documentElement.clientWidth;
const ch = document.documentElement.clientHeight;
const bodyh = document.documentElement.scrollHeight;
const scrollh = document.documentElement.scrollHeight;
const bodyh = document.body.offsetHeight;
var style = window.getComputedStyle(document.body);
const extraspaceX = parseFloat(style.marginLeft)+parseFloat(style.paddingLeft)+parseFloat(style.borderLeftWidth);
const extraspaceY = parseFloat(style.marginTop)+parseFloat(style.paddingTop)+parseFloat(style.borderTopWidth);
Expand Down Expand Up @@ -209,7 +210,13 @@ export class FeatherGridContextMenu extends GridContextMenu {
}

hitx = hitx - extraspaceX;
hity = hity - bodyh + extraspaceY;

// Following conditional branch accounts for incorrect math if body height is less than document height (no Y scrollbar)
if (scrollh == ch) {
hity = hity - bodyh;
} else {
hity = hity - scrollh + extraspaceY;
}

// Update the position of the menu to the computed position.
this._menu.node.style.transform = `translate(${Math.max(0, hitx)}px, ${hity}px`;
Expand Down
Loading