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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix topChrome not auto-hiding in React custom UIs #55

Merged
merged 8 commits into from
Mar 18, 2024

Conversation

MattiasBuelens
Copy link
Collaborator

React creates a <div style="display: contents"> to hold its topChrome/centerChrome/... elements, so it can set the correct slot attribute on that <div>. However, when the UI auto-hides, it sets opacity: 0 on its slotted children (with ::slotted(*), see UIContainer.css). Because of the display: contents, the opacity is ignored (since the <div> isn't really "displayed"), and so auto-hide doesn't work.

Fix it by adding a dedicated <theoplayer-slot-container> element. This behaves pretty much like a <div style="display: contents">, except that its slotted children have opacity: inherit. So when <theoplayer-slot-container> gets an opacity style from <theoplayer-ui-container>, it gets correctly forwarded to its children, and auto-hide works again! 馃榿

I also took this opportunity to make <theoplayer-slot-container> "transparent" for things like <theoplayer-menu-group> and <theoplayer-radio-group>. Usually, those elements expect their menus and radio buttons to be slotted in as direct children, but now they also allow them to be wrapped in a <theoplayer-slot-container>. This enables Open Video UI for React to use them for the menu prop of its <UIContainer> too. 馃檪

@MattiasBuelens
Copy link
Collaborator Author

I also think the no-auto-hide attribute doesn't work properly in React, because of extra wrapper <theoplayer-slot-container>. It probably didn't work previously either, when we were still using <div style="display: contents">. 馃槵

Not sure how I'm going to fix that though... We're currently using ::slotted(:not([no-auto-hide])), but that only targets direct children. And you're not even allowed to use a complex selector... 馃槙

@MattiasBuelens
Copy link
Collaborator Author

CC @tvanlaerhoven: This should fix the problem you've reported. Expect a new release soon. 馃槈

Bonus: no-auto-hide now also works in React! Example usage:

<UIContainer
  centeredChrome={<PlayButton no-auto-hide="" />}
/>

Copy link
Member

@georgechoustoulakis georgechoustoulakis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

@MattiasBuelens MattiasBuelens merged commit 21c8622 into main Mar 18, 2024
1 check passed
@MattiasBuelens MattiasBuelens deleted the slot-container branch March 18, 2024 10:37
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

Successfully merging this pull request may close these issues.

None yet

2 participants