Skip to content

Commit 4521912

Browse files
authored
fix: VirtualizedTable event handler types (#92)
Only the return value of `onKeyDown` is used by Zotero. We should mark the return type of other handlers as `void`: https://github.com/zotero/zotero/blob/7.0.25/chrome/content/zotero/components/virtualized-table.jsx#L380-L389 Besides, the `onActivate` handler takes not only the event itself, but also a list of selected items: https://github.com/zotero/zotero/blob/7.0.25/chrome/content/zotero/components/virtualized-table.jsx#L753-L760
1 parent cbad55e commit 4521912

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/helpers/virtualizedTable.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ export class VirtualizedTableHelper extends BasicTool {
111111
* // If you want to perform custom key handling it should be in this function
112112
* // if it returns false then virtualized-table's own key handler won't run
113113
* onKeyDown?: (e: Event) => boolean;
114-
* onKeyUp?: (e: Event) => boolean;
115-
* onDragOver?: (e: Event) => boolean;
116-
* onDrop?: (e: Event) => boolean;
114+
* onKeyUp?: (e: Event) => void;
115+
* onDragOver?: (e: Event) => void;
116+
* onDrop?: (e: Event) => void;
117117
* // Enter, double-clicking
118-
* onActivate?: (e: Event) => boolean;
119-
* onFocus?: (e: Event) => boolean;
120-
* onItemContextMenu?: (e: Event, x: number, y: number) => boolean;
118+
* onActivate?: (e: Event, items: number[]) => void;
119+
* onFocus?: (e: Event) => void;
120+
* onItemContextMenu?: (e: Event, x: number, y: number) => void;
121121
* }
122122
* ```
123123
*/
@@ -289,21 +289,21 @@ interface VirtualizedTableProps {
289289
// If you want to perform custom key handling it should be in this function
290290
// if it returns false then virtualized-table's own key handler won't run
291291
onKeyDown?: (e: KeyboardEvent) => boolean;
292-
onKeyUp?: (e: KeyboardEvent) => boolean;
292+
onKeyUp?: (e: KeyboardEvent) => void;
293293

294-
onDragOver?: (e: DragEvent) => boolean;
295-
onDrop?: (e: DragEvent) => boolean;
294+
onDragOver?: (e: DragEvent) => void;
295+
onDrop?: (e: DragEvent) => void;
296296

297297
// Enter, double-clicking
298-
onActivate?: (e: MouseEvent) => boolean;
298+
onActivate?: (e: MouseEvent | KeyboardEvent, items: number[]) => void;
299299

300-
onFocus?: (e: FocusEvent) => boolean;
300+
onFocus?: (e: FocusEvent) => void;
301301

302302
onItemContextMenu?: (
303303
e: MouseEvent | KeyboardEvent,
304304
x: number,
305305
y: number,
306-
) => boolean;
306+
) => void;
307307
}
308308

309309
interface VirtualizedTableConstructor

0 commit comments

Comments
 (0)