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

🐛 Fix amp-story-player panel next/prev button in Chrome #40124

Merged
merged 3 commits into from
Oct 25, 2024

Conversation

ychsieh
Copy link
Contributor

@ychsieh ychsieh commented Aug 22, 2024

#40119

I suppose this is more of a temporary bug in Chrome. But at the same time I don't think we need these rules to hide buttons for other non-panel modes, because full-bleed should be the only non-panel mode(which is already included this rule set).

Adding @processprocess as the contributor of these rules to make sure I don't miss anything.

Updated:
It turns out to be ancestor selector issue: :not(.i-amphtml-story-player-panel) .i-amphtml-story-player-panel-prev would also select .i-amphtml-story-player-panel-prev even though the immediate parent has .i-amphtml-story-player-panel so the button has opacity 0. This is because it's also directly within the tag, which does not have .i-amphtml-story-player-panel. Changing the ancestor selector to child selector solves the issue.

As for the reason why this previously works on other browsers like Safari and Firefox, my theory is that Chrome traces the ancestors all the way out of shadow root, e.g. , whereas Safari and Firefox don't. This means for this specific DOM tree in Safari and Firefox, ancestor and child selector has the same effect as the only ancestor is the parent, e.g. root element under shadow root.

@processprocess
Copy link
Contributor

This makes the buttons appear when they shouldn't.
For this reason I don't think we should merge this change.

This can be seen in the examples when running the dev server:
/examples/amp-story/player-amp-desktop-panels.html
/examples/amp-story/player-with-button.html
/examples/amp-story/player.html
/examples/amp-story/player-local-stories.html

Screenshot 2024-10-01 at 4 01 26 PM

erwinmombay
erwinmombay previously approved these changes Oct 3, 2024
Copy link
Member

@erwinmombay erwinmombay left a comment

Choose a reason for hiding this comment

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

solution doesnt work per @processprocess

@erwinmombay erwinmombay dismissed their stale review October 3, 2024 17:58

needs changes

@ychsieh ychsieh requested a review from processprocess October 7, 2024 21:50
@ychsieh
Copy link
Contributor Author

ychsieh commented Oct 7, 2024

It turns out to be ancestor selector issue: :not(.i-amphtml-story-player-panel) .i-amphtml-story-player-panel-prev would also select .i-amphtml-story-player-panel-prev even though the immediate parent has .i-amphtml-story-player-panel so the button has opacity 0. This is because it's also directly within the tag, which does not have .i-amphtml-story-player-panel. Changing the ancestor selector to child selector solves the issue.

As for the reason why this previously works on other browsers like Safari and Firefox, my theory is that Chrome traces the ancestors all the way out of shadow root, e.g. , whereas Safari and Firefox don't. This means for this specific DOM tree in Safari and Firefox, ancestor and child selector has the same effect as the only ancestor is the parent, e.g. root element under shadow root.

@ychsieh ychsieh requested a review from erwinmombay October 9, 2024 21:12
@ychsieh ychsieh merged commit f58f797 into ampproject:main Oct 25, 2024
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants