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

model-viewer disappears with dir=rtl and a certain combination of CSS size definitions #4930

Open
eyaler opened this issue Nov 7, 2024 · 3 comments

Comments

@eyaler
Copy link

eyaler commented Nov 7, 2024

Here is a minimal code. Please note this is a simplified version of an actual use case.

model-viewer version 4.0.0. Tested on Firefox 132 and Chromium 132.

I have an HTML with dir=rtl

I have CSS as such for responsive model size:

model-viewer {
    aspect-ratio: 1;
    height: auto;
}

And I have two model-viewers.

All of this works fine. But if i add width: 100% to the second model-viewer the first one disappears. changing to dir=ltr or adding direction: ltr in CSS fixes this. This was super hard to pin down...

@elalish
Copy link
Contributor

elalish commented Nov 7, 2024

Thanks, that is quite odd. Ideally MV just behaves the way a regular <div> would. Can you repro this behavior with just a standard <div> or <img> tag? If you figure out what CSS we have that's messing this up, a PR would be most welcome.

@eyaler
Copy link
Author

eyaler commented Nov 8, 2024

Thanks @elalish. This doesn't happen with div/img. you can see the loading and prompt are in the correct position but the model is shifted left out of the view. e.g with width: 70%:
Image

Also, if you play width the width on both model-viewers you can get strange artifacts where one of the models gets a duplicated view in different sizes:
Image
It reminded me of this old issue: #1379

I think the issue is related to RTL support (also found: #2021). As mentioned, a quick fix is adding dir=ltr or direction: ltr to the model-viewer, but adding that blindly might break backward compatibility and it would be better to understand the source of the issue (which is currently out of scope for me unfortunately). Maybe for the time being add a known issue comment to the docs?

@elalish
Copy link
Contributor

elalish commented Nov 13, 2024

Thanks for the detail, that's helpful. I'll take a look.

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

No branches or pull requests

2 participants