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

[LWC] Column header menus are not aligned correctly #2307

Closed
bmblb opened this issue Jan 29, 2021 · 4 comments
Closed

[LWC] Column header menus are not aligned correctly #2307

bmblb opened this issue Jan 29, 2021 · 4 comments
Assignees
Labels
bug Something isn't working forum Issues from forum high-priority Urgent to have fixed salesforce Salesforce integration

Comments

@bmblb
Copy link

bmblb commented Jan 29, 2021

Forum post

When the Grid is placed inside of a Lightning "modal dialog", its column header context menus are displayed off point, making them unusable.

This is because one of the modal dialog component's elements has 'slds-modal__container' class which applies translate(0, 0) transformation, effectively shrinking the .b-float-root element horizontally. This confuses menu positioning as it is relative to the float root yet the click point is relative to the window.

The following override resolves the issue (for us).

const getWidgetHost = () => getLWCElement().firstChild;
const getFloatRoot = () => getWidgetHost().querySelector('.b-float-root');

class RectangleOverride {
    static get target() {
        return {
            class: Rectangle,
        };
    }

/**
 * @override Rectangle.prototype.alignTo()
 */
alignTo(spec) {
    const { constrainTo } = spec;

    const result = this._overridden.alignTo.call(this, spec);

    if (constrainTo === window || constrainTo === document) {
        const { x } = Rectangle.from(getFloatRoot());

        // Compensate for the position shift
        // caused by slds-modal__container's
        // CSS transform: translate(0, 0);
        result.translate(-x, 0);
    }

    return result;
}
}
@bmblb bmblb added bug Something isn't working forum Issues from forum salesforce Salesforce integration labels Jan 29, 2021
@bmblb bmblb self-assigned this Jan 29, 2021
@bmblb bmblb changed the title [LWC] Disappearing month/year selector in date picker [LWC] Column header menus are not aligned correctly Feb 1, 2021
@bmblb
Copy link
Author

bmblb commented Feb 1, 2021

Without override
image
with override
image

@bmblb
Copy link
Author

bmblb commented Dec 5, 2022

Another mention on the forum: https://forum.bryntum.com/viewtopic.php?p=114594#p114594

@bmblb
Copy link
Author

bmblb commented Jul 11, 2023

Update: we can reproduce this behavior by adding LWC with Grid component to a default lightnint-modal component and calling menu

@matsbryntse matsbryntse added the high-priority Urgent to have fixed label Jan 8, 2024
@bmblb
Copy link
Author

bmblb commented Feb 6, 2024

Fixed by #7681

@bmblb bmblb closed this as completed Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working forum Issues from forum high-priority Urgent to have fixed salesforce Salesforce integration
Projects
None yet
Development

No branches or pull requests

2 participants