Skip to content

Commit

Permalink
fix: exclude role dialog from container show/hide
Browse files Browse the repository at this point in the history
  • Loading branch information
luwes committed Nov 25, 2024
1 parent e74b77c commit 0d2016e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
10 changes: 4 additions & 6 deletions src/js/media-chrome-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ function getTemplateHTML(_attrs: Record<string, string>) {
height: 100%;
justify-content: center;
align-items: center;
transition: visibility .15s ease-in, opacity .15s ease-in, transform .15s ease-in !important;
transition: visibility .15s ease-in, opacity .15s ease-in, transform .15s ease-in;
visibility: hidden;
${/* Prevent opacity override by media-container */ ''}
opacity: 0 !important;
opacity: 0;
transform: translateY(2px) scale(.99);
pointer-events: none;
}
:host([open]) {
visibility: visible;
opacity: 1 !important;
${/* Prevent transition override by media-container */ ''}
transition: visibility 0s, opacity .2s ease-out, transform .15s ease-out !important;
opacity: 1;
transition: visibility 0s, opacity .2s ease-out, transform .15s ease-out;
transform: translateY(0) scale(1);
}
Expand Down
38 changes: 19 additions & 19 deletions src/js/media-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ template.innerHTML = /*html*/ `
*/ ''
}
:host(:not([${Attributes.AUDIO}])[${
Attributes.GESTURES_DISABLED
}]) ::slotted([slot=gestures-chrome]),
Attributes.GESTURES_DISABLED
}]) ::slotted([slot=gestures-chrome]),
:host(:not([${Attributes.AUDIO}])[${
Attributes.GESTURES_DISABLED
}]) media-gesture-receiver[slot=gestures-chrome] {
Attributes.GESTURES_DISABLED
}]) media-gesture-receiver[slot=gestures-chrome] {
display: none;
}
Expand Down Expand Up @@ -151,7 +151,7 @@ template.innerHTML = /*html*/ `
${/* Only add these if auto hide is not disabled */ ''}
::slotted(:not([slot=media]):not([slot=poster]):not([${
Attributes.NO_AUTOHIDE
}]):not([hidden])) {
}]):not([hidden]):not([role=dialog])) {
opacity: 1;
transition: opacity 0.25s;
}
Expand All @@ -160,23 +160,23 @@ template.innerHTML = /*html*/ `
/* Hide controls when inactive, not paused, not audio and auto hide not disabled */ ''
}
:host([${Attributes.USER_INACTIVE}]:not([${
MediaUIAttributes.MEDIA_PAUSED
}]):not([${MediaUIAttributes.MEDIA_IS_AIRPLAYING}]):not([${
MediaUIAttributes.MEDIA_IS_CASTING
}]):not([${
Attributes.AUDIO
}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${
Attributes.NO_AUTOHIDE
}])) {
MediaUIAttributes.MEDIA_PAUSED
}]):not([${MediaUIAttributes.MEDIA_IS_AIRPLAYING}]):not([${
MediaUIAttributes.MEDIA_IS_CASTING
}]):not([${
Attributes.AUDIO
}])) ::slotted(:not([slot=media]):not([slot=poster]):not([${
Attributes.NO_AUTOHIDE
}]):not([role=dialog])) {
opacity: 0;
transition: opacity 1s;
}
:host([${Attributes.USER_INACTIVE}]:not([${
MediaUIAttributes.MEDIA_PAUSED
}]):not([${MediaUIAttributes.MEDIA_IS_CASTING}]):not([${
Attributes.AUDIO
}])) ::slotted([slot=media]) {
MediaUIAttributes.MEDIA_PAUSED
}]):not([${MediaUIAttributes.MEDIA_IS_CASTING}]):not([${
Attributes.AUDIO
}])) ::slotted([slot=media]) {
cursor: none;
}
Expand All @@ -188,8 +188,8 @@ template.innerHTML = /*html*/ `
/* ::slotted([slot=poster]) doesn't work for slot fallback content so hide parent slot instead */ ''
}
:host(:not([${Attributes.AUDIO}])[${
MediaUIAttributes.MEDIA_HAS_PLAYED
}]) slot[name=poster] {
MediaUIAttributes.MEDIA_HAS_PLAYED
}]) slot[name=poster] {
display: none;
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/media-error-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class MediaErrorDialog extends MediaChromeDialog {
attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {
super.attributeChangedCallback(attrName, oldValue, newValue);

// Add this conditional to prevent endless loop by setting the hidden attribute.
// Add this conditional to prevent endless loop by setting the open attribute.
if (!observedAttributes.includes(attrName)) return;

this.open = shouldOpenErrorDialog(this.mediaErrorCode);
Expand Down

0 comments on commit 0d2016e

Please sign in to comment.