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;
self.originalUrl = window.location.href;
const activeElement = document.activeElement;
@ -158,7 +158,7 @@ function DialogHashHandler(dlg, hash, resolve, dlgOptions) {
dlg.classList.remove('hide');
addBackdropOverlay(dlg, dlgOptions);
addBackdropOverlay(dlg);
dlg.classList.add('opened');
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');
backdrop.classList.add('dialogBackdrop');
@ -205,33 +205,35 @@ function addBackdropOverlay(dlg, dlgOptions = {}) {
void backdrop.offsetWidth;
backdrop.classList.add('dialogBackdropOpened');
if (!dlgOptions.preventCloseOnClick) {
dom.addEventListener((dlg.dialogContainer || backdrop), 'click', e => {
if (e.target === dlg.dialogContainer) {
close(dlg);
}
}, {
passive: true
});
}
let clickedElement;
if (!dlgOptions.preventCloseOnRightClick) {
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();
}
});
}
dom.addEventListener((dlg.dialogContainer || backdrop), 'mousedown', e => {
clickedElement = e.target;
});
dom.addEventListener((dlg.dialogContainer || backdrop), 'click', e => {
if (e.target === dlg.dialogContainer && e.target == clickedElement) {
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) {
return dlg.getAttribute('data-history') === 'true';
}
export function open(dlg, dlgOptions) {
export function open(dlg) {
if (globalOnOpenCallback) {
globalOnOpenCallback(dlg);
}
@ -248,7 +250,7 @@ export function open(dlg, dlgOptions) {
document.body.appendChild(dialogContainer);
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);
}
dialogHelper.open(dlg, {
preventCloseOnClick : true,
preventCloseOnRightClick : true
});
dialogHelper.open(dlg);
dlg.addEventListener('close', function () {
if (layoutManager.tv) {