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

[overlay] Overlay dir attribute not updated on re-opening after setting dir to RTL #7676

Closed
web-padawan opened this issue Aug 20, 2024 · 0 comments · Fixed by #7677
Closed
Labels
bug Something isn't working RTL Right-to-left issue vaadin-overlay vaadin-popover vaadin-tooltip

Comments

@web-padawan
Copy link
Member

Description

When using vaadin-tooltip or vaadin-popover that uses e.g. bottom-start position, it isn't correctly flipped horizontally once the dir attribute on the document is set to rtl.

This is apparently caused by this logic that checks computedStyle() on first open and then sets attribute without relying on the global dir value available through DirMixin:

this.setAttribute('dir', computedStyle.direction);

Expected outcome

I would expect the dir attribute to apply to the overlay so that horizontal alignment would be updated correctly.

Expected alignment

Screenshot 2024-08-20 at 12 02 32

Actual alignment

Screenshot 2024-08-20 at 12 02 11

Minimal reproducible example

<div style="max-width: 100px; margin: 0 auto">
  <button id="button">Toggle RTL</button>
</div>
<vaadin-tooltip
  text="Switch document direction"
  for="button"
  position="bottom-start"
></vaadin-tooltip>
<script type="module">
  import '@vaadin/tooltip';

  const button = document.querySelector('button');
  button.addEventListener('click', () => {
    if (document.dir === 'rtl') {
      document.dir = '';
    } else {
      document.dir = 'rtl';
    }
  });
</script>

Steps to reproduce

  1. Move mouse to the button, note the tooltip overlay position
  2. Click the button to toggle document dir
  3. Move mouse to the button again, the position is the same

Environment

Vaadin version(s): 24.5 and earlier

Browsers

Issue is not browser related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working RTL Right-to-left issue vaadin-overlay vaadin-popover vaadin-tooltip
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant