Premium support for our pure JavaScript UI components


Post by gbrdhvndi »

In Salesforce Lightning Experience (LEX), the document body height is always 0px and full window scroll is not being used. Instead, the content of each "page" the user navigates to within LEX is placed into a scrollable div.

This messes up position calculation and makes some components unusable. For instance, the date picker's month and year selectors are shifted off screen making month/year label simply disappear on mouse hover.

I have sucessfully worked around this issue by creating the following override but wanted to validate whether this is the correct approach or is there anything else I could do to improve it?

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

/**
 * @override Core/helper/util/Rectangle.from()
 */
static from(element, relativeTo, ignorePageScroll) {
    const result = this._overridden.from.call(this, ...arguments);

    if (element === document.body) {
        // In LEX, the document.body height is always 0px
        // which messes up relative position calculations.
        result.height = window.innerHeight;
    }

    return result;
}
}

Thank you

Aleksei


Post by Maxim Gorkovsky »

Hi Aleksei,
we just got this issue fixed for LWC for the upcoming 4.1.0 release. You got right to the reason of the failure - our code doesn't handle body with 0 height. Override looks correct and safe.

Stay tuned, we got more good news coming about LWC support :)


Post by gbrdhvndi »

Sweet! :-)

Thanks Maxim!

Aleksei


Post by gbrdhvndi »

Here is another one for you then.

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;
}
}

Aleksei


Post by Maxim Gorkovsky »

Aleksei, thank you for report, I opened a ticket to track this issue: https://github.com/bryntum/support/issues/2307


Post by gbrdhvndi »

Thank you for picking this up.

Although the second override is not for the date picker's month/year editors but is for the column header menus.

This is how it looks without the override:

modal_grid_menu_nooverride.png
modal_grid_menu_nooverride.png (225.62 KiB) Viewed 1606 times

And here is the overridden version:

modal_grid_menu_overridden.png
modal_grid_menu_overridden.png (225.97 KiB) Viewed 1606 times

All because of the modal dialog styling.
https://www.lightningdesignsystem.com/components/modals/

Specifically, the slds-modal__container CSS class.

Aleksei


Post by Maxim Gorkovsky »

Ticket updated, thank you for heads up!


Post Reply