apply the save shortcut only for the top open modal
This commit is contained in:
@@ -259,3 +259,11 @@ function findLargestZIndexModal(excludeEl) {
|
||||
|
||||
return largest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current top-most open modal element.
|
||||
* @return {Element|undefined}
|
||||
*/
|
||||
window.app.modals.getTop = function() {
|
||||
return findLargestZIndexModal();
|
||||
};
|
||||
|
||||
@@ -265,8 +265,13 @@ function collectionUpsertModal(rawCollection, modalSettings) {
|
||||
className: "modal collection-upsert-modal",
|
||||
inert: () => data.isSaving,
|
||||
onkeydown: (e) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.code == "KeyS") {
|
||||
if (
|
||||
(e.ctrlKey || e.metaKey)
|
||||
&& e.code == "KeyS"
|
||||
&& app.modals.getTop() === modal
|
||||
) {
|
||||
e.preventDefault();
|
||||
|
||||
// temp blur any active input to make sure that onchange/blur events are fired
|
||||
const input = document.activeElement;
|
||||
input?.blur();
|
||||
|
||||
@@ -197,8 +197,11 @@
|
||||
}
|
||||
|
||||
.field-type-bool {
|
||||
&.record-field-view .label {
|
||||
min-width: 48px;
|
||||
&.record-field-view {
|
||||
min-width: auto;
|
||||
.label {
|
||||
min-width: 48px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -421,7 +421,11 @@ function recordUpsertModal(collection, rawRecord, modalSettings) {
|
||||
inert: () => data.isLoading || data.isSaving,
|
||||
onmount: (el) => {
|
||||
el._quickSaveHandler = (e) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.code == "KeyS") {
|
||||
if (
|
||||
(e.ctrlKey || e.metaKey)
|
||||
&& e.code == "KeyS"
|
||||
&& app.modals.getTop() === el?.closest(".modal")
|
||||
) {
|
||||
e.preventDefault();
|
||||
save(false);
|
||||
}
|
||||
@@ -430,7 +434,7 @@ function recordUpsertModal(collection, rawRecord, modalSettings) {
|
||||
},
|
||||
onunmount: (el) => {
|
||||
if (el?._quickSaveHandler) {
|
||||
window.removeEventListener("keydown", el?._quickSaveHandler);
|
||||
window.removeEventListener("keydown", el._quickSaveHandler);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user