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

Svelte 5: non-keyed each blocks do not retain text direction in elements with dir="auto" #12193

Closed
navorite opened this issue Jun 26, 2024 · 2 comments · Fixed by #12204
Closed
Assignees
Labels
Milestone

Comments

@navorite
Copy link
Contributor

navorite commented Jun 26, 2024

Describe the bug

If an element i.e. a <p> tag has dir="auto" attribute value, when Svelte replaces the elements after deleting/showing/hiding some of the elements, they do not retain the direction of the text instead it takes the direction of the element that Svelte replaced.

There are two workarounds for this, one is to change it to a keyed each block, (but that also has some bugs where elements overlap each other and their order becomes messed up but I'm trying to narrow it down to open a bug If I have enough time for it as well) and the other is to use a useless {#key} block to force Svelte to re-render each item.

Regardless of all this, the behavior of Svelte 4 is the correct behavior where the direction is always retained.

Reproduction

Out of Firefox and Chrome, It occurs on Chrome only for me.

To reproduce: Fav second item and then click on Fav button.

Notice that on the non-keyed each block the new element inherits the text direction of the element that was replaced therefore changing the direction.

Correct behavior: Svelte 4

Wrong behavior: Svelte 5

Logs

No response

System Info

svelte 5.0.0-next.166

Severity

annoyance

@navorite navorite changed the title Svelte 5: non-keyed each blocks do not retain dir="auto" Svelte 5: non-keyed each blocks do not retain text direction in elements with dir="auto" Jun 26, 2024
@dummdidumm
Copy link
Member

To reproduce: Fav second item, click on on "Fav", see that non-keyed text changes direction

@dummdidumm dummdidumm added this to the 5.0 milestone Jun 27, 2024
@dummdidumm dummdidumm added the bug label Jun 27, 2024
@navorite
Copy link
Contributor Author

navorite commented Jun 27, 2024

I noticed that this doesn't occur on Firefox that's why I couldn't reproduce it on the REPL but it turns out it is reproducible on the REPL when using Chrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants