Skip to content

Commit 58e4d45

Browse files
authored
Fix some situations where clicks were ignored (#3786)
1 parent 58eb856 commit 58e4d45

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

resources/js/composables/album/dragAndSelect.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,16 @@ export function useDragAndSelect(
119119
return true;
120120
}
121121

122+
function isInteractiveTarget(target: EventTarget | null): boolean {
123+
if (!(target instanceof HTMLElement)) return false;
124+
if (target.closest("[data-stop-drag-select='true']")) return true;
125+
const interactiveSelectors =
126+
"a,button,input,textarea,select,summary,[role='button'],[role='menuitem'],[role='link'],.p-drawer-mask,.p-speeddial,.p-contextmenu,.p-dialog";
127+
return target.closest(interactiveSelectors) !== null;
128+
}
129+
122130
function show(e: MouseEvent) {
123-
if (!canStart(e)) {
131+
if (!canStart(e) || isInteractiveTarget(e.target)) {
124132
return;
125133
}
126134

resources/js/composables/selections/selections.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TogglablesStateStore } from "@/stores/ModalsState";
2-
import { modKey, shiftKeyState } from "@/utils/keybindings-utils";
2+
import { getModKey } from "@/utils/keybindings-utils";
33
import { storeToRefs } from "pinia";
44
import { computed, ref } from "vue";
55
import { useAlbumActions } from "@/composables/album/albumActions";
@@ -60,12 +60,19 @@ export function useSelection(photosStore: PhotosStore, albumsStore: AlbumsStore,
6060
selectedAlbumsIdx.value = selectedAlbumsIdx.value.filter((i) => i !== idx);
6161
}
6262

63-
function photoSelect(idx: number, e: Event): void {
63+
function getMouseModifiers(e: MouseEvent): { isMod: boolean; isShift: boolean } {
64+
const modKey = getModKey();
65+
const isMod = modKey === "Meta" ? e.metaKey : e.ctrlKey;
66+
return { isMod, isShift: e.shiftKey };
67+
}
68+
69+
function photoSelect(idx: number, e: MouseEvent): void {
6470
// clear the Album selection.
6571
selectedAlbumsIdx.value = [];
6672

6773
// we do not support CTRL + SHIFT
68-
if (!modKey().value && !shiftKeyState.value) {
74+
const { isMod, isShift } = getMouseModifiers(e);
75+
if (!isMod && !isShift) {
6976
return;
7077
}
7178

@@ -77,12 +84,12 @@ export function useSelection(photosStore: PhotosStore, albumsStore: AlbumsStore,
7784
return;
7885
}
7986

80-
if (modKey().value) {
87+
if (isMod) {
8188
handlePhotoCtrl(idx, e);
8289
return;
8390
}
8491

85-
if (shiftKeyState.value) {
92+
if (isShift) {
8693
handlePhotoShift(idx, e);
8794
return;
8895
}
@@ -126,12 +133,13 @@ export function useSelection(photosStore: PhotosStore, albumsStore: AlbumsStore,
126133
lastPhotoClicked.value = idx;
127134
}
128135

129-
function albumClick(idx: number, e: Event): void {
136+
function albumClick(idx: number, e: MouseEvent): void {
130137
// clear the Photo selection.
131138
selectedPhotosIdx.value = [];
132139

133140
// we do not support CTRL + SHIFT
134-
if (!modKey().value && !shiftKeyState.value) {
141+
const { isMod, isShift } = getMouseModifiers(e);
142+
if (!isMod && !isShift) {
135143
return;
136144
}
137145

@@ -143,12 +151,12 @@ export function useSelection(photosStore: PhotosStore, albumsStore: AlbumsStore,
143151
return;
144152
}
145153

146-
if (modKey().value) {
154+
if (isMod) {
147155
handleAlbumCtrl(idx, e);
148156
return;
149157
}
150158

151-
if (shiftKeyState.value) {
159+
if (isShift) {
152160
handleAlbumShift(idx, e);
153161
return;
154162
}

resources/sass/app.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ html {
194194
outline-offset: 0px;
195195
}
196196

197+
/* PrimeVue overlays linger briefly during exit animations; disable pointer events
198+
so the fading mask no longer swallows the user's next click. */
199+
.p-component-overlay-leave-active {
200+
pointer-events: none;
201+
}
202+
197203
.filter-shadow {
198204
filter: drop-shadow(0 0 0.5rem black);
199205
}

0 commit comments

Comments
 (0)