Skip to content

Commit dd4164e

Browse files
sampottscursoragent
andcommitted
fix(html): keep translated error description during dialog close
Preserve the last resolved description key while the dialog is closing so locale-aware copy does not flash back to English before unmount. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d2e37dc commit dd4164e

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

packages/html/src/ui/error-dialog/error-dialog-element.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
getErrorDialogTitleLabel,
77
type MediaError,
88
resolveErrorDialogDescription,
9+
type TranslationKeyOrString,
910
} from '@videojs/core';
1011
import {
1112
type AlertDialogApi,
@@ -40,6 +41,7 @@ export class ErrorDialogElement extends MediaElement {
4041
#dialog: AlertDialogApi | null = null;
4142
#snapshot: SnapshotController<AlertDialogInput> | null = null;
4243
#lastError: MediaError | null = null;
44+
#lastDescription: TranslationKeyOrString | null = null;
4345

4446
constructor() {
4547
super();
@@ -92,6 +94,7 @@ export class ErrorDialogElement extends MediaElement {
9294

9395
if (!hasError && !isOpen) {
9496
this.#lastError = null;
97+
this.#lastDescription = null;
9598
}
9699

97100
if (hasError && !isOpen) {
@@ -128,8 +131,12 @@ export class ErrorDialogElement extends MediaElement {
128131

129132
const desc = this.querySelector('media-alert-dialog-description');
130133
if (desc) {
131-
const description = resolveErrorDialogDescription(error);
132-
desc.textContent = resolveTranslationPhrase(t, description);
134+
const description = error ? resolveErrorDialogDescription(error) : null;
135+
if (description) {
136+
this.#lastDescription = description;
137+
}
138+
const copy = description ?? this.#lastDescription ?? 'mediaErrorFallback';
139+
desc.textContent = resolveTranslationPhrase(t, copy);
133140
}
134141

135142
const close = this.querySelector('media-alert-dialog-close');

0 commit comments

Comments
 (0)