diff --git a/apps/client/src/widgets/launch_bar/BookmarkButtons.tsx b/apps/client/src/widgets/launch_bar/BookmarkButtons.tsx index e2b5b5216..76286c288 100644 --- a/apps/client/src/widgets/launch_bar/BookmarkButtons.tsx +++ b/apps/client/src/widgets/launch_bar/BookmarkButtons.tsx @@ -49,7 +49,7 @@ function BookmarkFolder({ note }: { note: FNote }) { diff --git a/apps/client/src/widgets/launch_bar/Calendar.tsx b/apps/client/src/widgets/launch_bar/Calendar.tsx index 38aaa8bfc..d619f768c 100644 --- a/apps/client/src/widgets/launch_bar/Calendar.tsx +++ b/apps/client/src/widgets/launch_bar/Calendar.tsx @@ -63,7 +63,7 @@ function CalendarWeekHeader({ rawFirstDayOfWeek }: { rawFirstDayOfWeek: number } return (
- {localeDaysOfWeek.map(dayOfWeek => {dayOfWeek})} + {localeDaysOfWeek.map(dayOfWeek => {dayOfWeek})}
) } @@ -79,7 +79,7 @@ function PreviousMonthDays({ date, info: { dates, weekNumbers }, ...args }: { da return ( <> - {dates.map(date => )} + {dates.map(date => )} ) } @@ -98,10 +98,10 @@ function CurrentMonthDays({ date, firstDayOfWeekISO, ...args }: { date: Dayjs, f while (dateCursor.month() === currentMonth) { const weekNumber = getWeekNumber(dateCursor, firstDayOfWeekISO); if (dateCursor.isoWeekday() === firstDayOfWeekISO) { - items.push() + items.push() } - items.push() + items.push() dateCursor = dateCursor.add(1, "day"); } @@ -117,7 +117,7 @@ function NextMonthDays({ date, dates, ...args }: { date: Dayjs, dates: Dayjs[] } }, [ date ]); return dates.map(date => ( - + )); } diff --git a/apps/client/src/widgets/launch_bar/GenericButtons.tsx b/apps/client/src/widgets/launch_bar/GenericButtons.tsx index a348bef9a..9af775760 100644 --- a/apps/client/src/widgets/launch_bar/GenericButtons.tsx +++ b/apps/client/src/widgets/launch_bar/GenericButtons.tsx @@ -1,3 +1,4 @@ +import { useCallback } from "preact/hooks"; import appContext from "../../components/app_context"; import FNote from "../../entities/fnote"; import link_context_menu from "../../menus/link_context_menu"; @@ -13,11 +14,7 @@ export function CustomNoteLauncher({ launcherNote, getTargetNoteId, getHoistedNo }) { const { icon, title } = useLauncherIconAndTitle(launcherNote); - // Keyboard shortcut. - const [ shortcut ] = useNoteLabel(launcherNote, "keyboardShortcut"); - useGlobalShortcut(shortcut, launch); - - async function launch(evt: MouseEvent | KeyboardEvent) { + const launch = useCallback(async (evt: MouseEvent | KeyboardEvent) => { if (evt.which === 3) { return; } @@ -34,7 +31,11 @@ export function CustomNoteLauncher({ launcherNote, getTargetNoteId, getHoistedNo } else { await appContext.tabManager.openInSameTab(targetNoteId); } - } + }, [ launcherNote, getTargetNoteId, getHoistedNoteId ]); + + // Keyboard shortcut. + const [ shortcut ] = useNoteLabel(launcherNote, "keyboardShortcut"); + useGlobalShortcut(shortcut, launch); return ( { if (launcherNote.isLabelTruthy("scriptInLauncherContent")) { await launcherNote.executeScript(); } else { @@ -62,7 +62,7 @@ export function ScriptLauncher({ launcherNote }: LauncherNoteProps) { await script.executeScript(); } } - } + }, [ launcherNote ]); // Keyboard shortcut. const [ shortcut ] = useNoteLabel(launcherNote, "keyboardShortcut"); diff --git a/apps/client/src/widgets/react/Dropdown.tsx b/apps/client/src/widgets/react/Dropdown.tsx index 51e38cfeb..18f060a86 100644 --- a/apps/client/src/widgets/react/Dropdown.tsx +++ b/apps/client/src/widgets/react/Dropdown.tsx @@ -48,7 +48,7 @@ export default function Dropdown({ id, className, buttonClassName, isStatic, chi const [ shown, setShown ] = useState(false); useEffect(() => { - if (!triggerRef.current || !dropdownContainerRef) return; + if (!triggerRef.current || !dropdownContainerRef.current) return; const dropdown = BootstrapDropdown.getOrCreateInstance(triggerRef.current, dropdownOptions); if (dropdownRef) { @@ -59,12 +59,9 @@ export default function Dropdown({ id, className, buttonClassName, isStatic, chi setShown(true); } - const dropdownContainer = dropdownContainerRef.current; - if (!dropdownContainer) return; - // React to popup container size changes, which can affect the positioning. const resizeObserver = new ResizeObserver(() => dropdown.update()); - resizeObserver.observe(dropdownContainer); + resizeObserver.observe(dropdownContainerRef.current); return () => { resizeObserver.disconnect();