1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Backport pull request #6421 from jellyfin-web/release-10.10.z

Fix metadata dialog backdrop click to exit

Original-merge: e1deddcba1

Merged-by: thornbill <thornbill@users.noreply.github.com>

Backported-by: thornbill <thornbill@users.noreply.github.com>
This commit is contained in:
viown 2025-01-22 03:12:47 -05:00 committed by thornbill
parent 34ace6bc11
commit ad09013bf2
2 changed files with 27 additions and 28 deletions

View file

@ -43,7 +43,7 @@ function tryRemoveElement(elem) {
} }
} }
function DialogHashHandler(dlg, hash, resolve, dlgOptions) { function DialogHashHandler(dlg, hash, resolve) {
const self = this; const self = this;
self.originalUrl = window.location.href; self.originalUrl = window.location.href;
const activeElement = document.activeElement; const activeElement = document.activeElement;
@ -158,7 +158,7 @@ function DialogHashHandler(dlg, hash, resolve, dlgOptions) {
dlg.classList.remove('hide'); dlg.classList.remove('hide');
addBackdropOverlay(dlg, dlgOptions); addBackdropOverlay(dlg);
dlg.classList.add('opened'); dlg.classList.add('opened');
dlg.dispatchEvent(new CustomEvent('open', { dlg.dispatchEvent(new CustomEvent('open', {
@ -193,7 +193,7 @@ function DialogHashHandler(dlg, hash, resolve, dlgOptions) {
} }
} }
function addBackdropOverlay(dlg, dlgOptions = {}) { function addBackdropOverlay(dlg) {
const backdrop = document.createElement('div'); const backdrop = document.createElement('div');
backdrop.classList.add('dialogBackdrop'); backdrop.classList.add('dialogBackdrop');
@ -205,33 +205,35 @@ function addBackdropOverlay(dlg, dlgOptions = {}) {
void backdrop.offsetWidth; void backdrop.offsetWidth;
backdrop.classList.add('dialogBackdropOpened'); backdrop.classList.add('dialogBackdropOpened');
if (!dlgOptions.preventCloseOnClick) { let clickedElement;
dom.addEventListener((dlg.dialogContainer || backdrop), 'click', e => {
if (e.target === dlg.dialogContainer) {
close(dlg);
}
}, {
passive: true
});
}
if (!dlgOptions.preventCloseOnRightClick) { dom.addEventListener((dlg.dialogContainer || backdrop), 'mousedown', e => {
dom.addEventListener((dlg.dialogContainer || backdrop), 'contextmenu', e => { clickedElement = e.target;
if (e.target === dlg.dialogContainer) { });
// Close the application dialog menu
close(dlg); dom.addEventListener((dlg.dialogContainer || backdrop), 'click', e => {
// Prevent the default browser context menu from appearing if (e.target === dlg.dialogContainer && e.target == clickedElement) {
e.preventDefault(); close(dlg);
} }
}); }, {
} passive: true
});
dom.addEventListener((dlg.dialogContainer || backdrop), 'contextmenu', e => {
if (e.target === dlg.dialogContainer) {
// Close the application dialog menu
close(dlg);
// Prevent the default browser context menu from appearing
e.preventDefault();
}
});
} }
function isHistoryEnabled(dlg) { function isHistoryEnabled(dlg) {
return dlg.getAttribute('data-history') === 'true'; return dlg.getAttribute('data-history') === 'true';
} }
export function open(dlg, dlgOptions) { export function open(dlg) {
if (globalOnOpenCallback) { if (globalOnOpenCallback) {
globalOnOpenCallback(dlg); globalOnOpenCallback(dlg);
} }
@ -248,7 +250,7 @@ export function open(dlg, dlgOptions) {
document.body.appendChild(dialogContainer); document.body.appendChild(dialogContainer);
return new Promise((resolve) => { return new Promise((resolve) => {
new DialogHashHandler(dlg, `dlg${new Date().getTime()}`, resolve, dlgOptions); new DialogHashHandler(dlg, `dlg${new Date().getTime()}`, resolve);
}); });
} }

View file

@ -1099,10 +1099,7 @@ function show(itemId, serverId, resolve) {
centerFocus(dlg.querySelector('.formDialogContent'), false, true); centerFocus(dlg.querySelector('.formDialogContent'), false, true);
} }
dialogHelper.open(dlg, { dialogHelper.open(dlg);
preventCloseOnClick : true,
preventCloseOnRightClick : true
});
dlg.addEventListener('close', function () { dlg.addEventListener('close', function () {
if (layoutManager.tv) { if (layoutManager.tv) {