chore: reactive hiding body scroll on modal

This commit is contained in:
2024-05-25 17:05:41 +02:00
parent 17d77a80d8
commit bcb9c63cb0
2 changed files with 7 additions and 7 deletions
+7
View File
@@ -29,8 +29,15 @@ export default defineComponent({
chosenTrain(train: Train | undefined) {
this.$nextTick(() => {
if (train) {
document.body.classList.add('no-scroll');
const contentEl = this.$refs['content'] as HTMLElement;
contentEl.focus();
} else {
(this.store.modalLastClickedTarget as any)?.focus();
setTimeout(() => {
document.body.classList.remove('no-scroll');
}, 90);
}
});
}
-7
View File
@@ -14,24 +14,17 @@ export default defineComponent({
methods: {
selectModalTrain(train: Train, target?: EventTarget | null) {
this.store.chosenModalTrainId = train.modalId;
document.body.classList.add('no-scroll');
if (target) this.store.modalLastClickedTarget = target;
},
selectModalTrainById(modalId: string, target?: EventTarget | null) {
this.store.chosenModalTrainId = modalId;
document.body.classList.add('no-scroll');
if (target) this.store.modalLastClickedTarget = target;
},
closeModal() {
this.store.chosenModalTrainId = undefined;
this.tooltipStore.hide();
setTimeout(() => {
(this.store.modalLastClickedTarget as any)?.focus();
document.body.classList.remove('no-scroll');
}, 150);
}
}
});