Merge pull request #605 from PR0M3TH3AN/codex/update-closeallmenus-and-related-callbacks

Fix focus restoration when closing video menus
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2025-10-16 18:17:49 -04:00
commit 69f5e02926
2 files changed
+11 -7

No files matched your search

+5 -3
View File
@@ -424,13 +424,15 @@ export default class MoreMenuController {
closeAllMoreMenus(options = {}) {
const skipView = options?.skipView === true;
const restoreFocus = options?.restoreFocus !== false;
if (!skipView && this.videoListView && typeof this.videoListView.closeAllMenus === "function") {
this.videoListView.closeAllMenus({ skipController: true });
this.videoListView.closeAllMenus({
skipController: true,
restoreFocus,
});
}
const restoreFocus = options?.restoreFocus !== false;
this.popoversByTrigger.forEach((entry) => {
if (entry?.popover && typeof entry.popover.close === "function") {
entry.popover.close({ restoreFocus });
+6 -4
View File
@@ -441,7 +441,7 @@ export class VideoListView {
},
ensureGlobalMoreMenuHandlers: () =>
this.utils.ensureGlobalMoreMenuHandlers(),
onRequestCloseAllMenus: () => this.closeAllMenus(),
onRequestCloseAllMenus: () => this.closeAllMenus({ restoreFocus: false }),
formatters: {
formatTimeAgo: this.formatters.formatTimeAgo,
},
@@ -1032,16 +1032,18 @@ export class VideoListView {
}
closeAllMenus(options = {}) {
const restoreFocus = options?.restoreFocus !== false;
if (Array.isArray(this.videoCardInstances) && this.videoCardInstances.length) {
this.videoCardInstances.forEach((card) => {
if (!card) {
return;
}
if (typeof card.closeMoreMenu === "function") {
card.closeMoreMenu();
card.closeMoreMenu({ restoreFocus });
}
if (typeof card.closeSettingsMenu === "function") {
card.closeSettingsMenu();
card.closeSettingsMenu({ restoreFocus });
}
});
}
@@ -1051,7 +1053,7 @@ export class VideoListView {
}
if (typeof this.utils.closeAllMenus === "function") {
this.utils.closeAllMenus({ skipView: true });
this.utils.closeAllMenus({ skipView: true, restoreFocus });
}
}