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

feat: add media-error-dialog #1024

Merged
merged 32 commits into from
Dec 5, 2024
Merged

feat: add media-error-dialog #1024

merged 32 commits into from
Dec 5, 2024

Conversation

luwes
Copy link
Contributor

@luwes luwes commented Nov 8, 2024

https://media-chrome-git-fork-luwes-error-dialog-mux.vercel.app/examples/vanilla/control-elements/media-error-dialog.html

use of <media-chrome-dialog> here:
https://media-chrome-git-fork-luwes-error-dialog-mux.vercel.app/examples/vanilla/control-elements/media-settings-menu.html

  • Simplified the media-chrome-dialog removing many CSS vars that are not essential.
  • Format the error message by overriding MediaErrorDialog.formatErrorMessage(error)
  • Change the error message via slots
<media-error-dialog mediaerrorcode="2">
  <div slot="error-2">This is a custom message</div>
</media-error-dialog>
  • Supports custom media elements errors with any code and message.
  • Built with React SSR compatible getTemplateHTML static methods (could be nice to start working towards this)

@luwes luwes self-assigned this Nov 8, 2024
@luwes luwes requested review from heff and a team as code owners November 8, 2024 16:43
Copy link

height bot commented Nov 8, 2024

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

Copy link

vercel bot commented Nov 8, 2024

@luwes is attempting to deploy a commit to the Mux Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Nov 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
media-chrome ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 7:51pm
media-chrome-demo-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 7:51pm
media-chrome-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 5, 2024 7:51pm

Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 92.62087% with 29 lines in your changes missing coverage. Please review.

Project coverage is 77.53%. Comparing base (3ea80df) to head (7bebf49).
Report is 139 commits behind head on main.

Files with missing lines Patch % Lines
src/js/media-chrome-dialog.ts 85.60% 18 Missing ⚠️
src/js/media-error-dialog.ts 96.06% 5 Missing ⚠️
src/js/utils/element-utils.ts 62.50% 3 Missing ⚠️
src/js/media-store/state-mediator.ts 92.30% 0 Missing and 2 partials ⚠️
src/js/labels/labels.ts 96.55% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1024      +/-   ##
==========================================
- Coverage   78.55%   77.53%   -1.03%     
==========================================
  Files          59       51       -8     
  Lines       11080    12329    +1249     
  Branches        0      724     +724     
==========================================
+ Hits         8704     9559     +855     
- Misses       2376     2742     +366     
- Partials        0       28      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@cjpillsbury cjpillsbury left a comment

Choose a reason for hiding this comment

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

Some starting questions (unrelated to prior central focus of prior convo). May not be blockers, depending

src/js/media-error-dialog.ts Show resolved Hide resolved
src/js/media-chrome-dialog.ts Show resolved Hide resolved
src/js/labels/labels.ts Outdated Show resolved Hide resolved
src/js/media-chrome-dialog.ts Show resolved Hide resolved
src/js/media-chrome-dialog.ts Show resolved Hide resolved
src/js/media-error-dialog.ts Outdated Show resolved Hide resolved
src/js/utils/element-utils.ts Show resolved Hide resolved
Co-authored-by: Christian Pillsbury <cjpillsbury@gmail.com>
Copy link
Collaborator

@heff heff left a comment

Choose a reason for hiding this comment

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

lgtm except this should show the error title
image

Also we're swallowing the custom error code and that doesn't seem right. I think we should instead create a title for unknown errors like "Error Code 42".

image

In the future we could give devs a way to override the title of a custom code.

src/js/media-error-dialog.ts Outdated Show resolved Hide resolved
@@ -1,5 +1,14 @@
export type LabelOptions = { seekOffset?: number; playbackRate?: number };

// Setting a code explicitely to null makes the error not show up in the UI.
export const errors = {
1: null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll be interested to see if there's any downsides of swallowing Code 1s completely. No change needed but I wonder if we should log a warning to the dev console.

src/js/media-error-dialog.ts Outdated Show resolved Hide resolved
examples/vanilla/control-elements/media-error-dialog.html Outdated Show resolved Hide resolved
::slotted([role="menu"]) {
align-self: end;
slot[name=dialog]::slotted(*) {
z-index: 2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not clear on why and I'm sure there's a good reason, but I wish we didn't need this. I've been bitten a lot by unintentional z-index layering.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@heff - I had the same question and @luwes gave a good (albeit unfortunate bc HTML + layout more generally) reason imo: it's because we already rely on z-indexing in other components (e.g. thumbnail for media-time-range). I called out making this an official css var just in case for those reasons.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in media-chrome-range the input[type=range] element is used as a hover zone which is 14px higher than the actual media-chrome-range. helps with dragging on mobile. it's primarily for layouts where the timeline goes right above the buttons and then it's better that the timeline slightly overlaps the buttons.

I can see the concerns though, we already had a report from Phil on this in the Mux dashboard with Mux players dialog being on z-index: 100.

I'll see if there is a workaround.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did some testing on Mux player with the z-indexes removed and that worked fine because we set them in the themes. maybe that's right approach. leave it up to the consumer of the MC elements?
I removed all the z-indexes in the last commit.

@luwes luwes merged commit 3fc95a2 into muxinc:main Dec 5, 2024
7 of 8 checks passed
@luwes luwes deleted the error-dialog branch December 5, 2024 21:22
luwes added a commit to luwes/elements that referenced this pull request Dec 5, 2024
luwes added a commit to muxinc/elements that referenced this pull request Dec 6, 2024
related #1012
requires muxinc/media-chrome#1024

- fixes an issue where the `.error` object could be null when the error
event is dispatched.
this was introduced when we started calling initialize() function
deferred in mux-video I believe.
this is fixed by saving the error state each time before we dispatch the
error event.
- the warning API is not implemented because after closer inspection we
don't really do much with non-fatal errors.
  the only thing is doing a console.warn here:

https://github.com/muxinc/elements/blob/1e1f24a18d7fe61c5b4bdfd9cf4cfb6d9d57b0ea/packages/mux-player/src/index.ts#L461-L465
we can easily do that in playback-core if we want?
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.

3 participants