vaadin / vaadin-date-picker

The Web Component providing a date selection field with scrollable month calendar. Part of the Vaadin components.

Home Page:https://vaadin.com/components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RTL: incorrect overlay position when closer to the left edge of viewport

pekam opened this issue · comments

In RTL mode, when the field is closer to the right edge of the viewport, it works as expected:
image

When the field is closer to the left edge, the overlay goes to the right side of the viewport:
image

It's related to the logic for flipping the overlay when closer to the other edge:

const rightAlign = inputRect.left + this.clientWidth / 2 > window.innerWidth / 2;
if (rightAlign) {
const viewportWidth = Math.min(window.innerWidth, document.documentElement.clientWidth);
this.$.overlay.setAttribute('right-aligned', '');
this.$.overlay.style.removeProperty('left');
this.$.overlay.style.right = (viewportWidth - inputRect.right) + 'px';
} else {
this.$.overlay.removeAttribute('right-aligned');
this.$.overlay.style.removeProperty('right');
this.$.overlay.style.left = inputRect.left + 'px';
}