From 9e04a1dcfa3bde6001df4d27f7f9a6ca01e883d2 Mon Sep 17 00:00:00 2001 From: Alex Christoffer Rasmussen Date: Sat, 27 Apr 2024 17:00:41 +0100 Subject: [PATCH] shortcuts using useHotkeys from mantine/hooks (#907) --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com> Co-authored-by: Carlos Valente --- .../input/auto-text-area/AutoTextArea.tsx | 16 +- .../components/input/text-input/TextInput.tsx | 58 ------ .../input/text-input/useReactiveTextInput.tsx | 63 +++--- .../client/src/common/hooks/useEventAction.ts | 2 +- apps/client/src/common/stores/appModeStore.ts | 2 +- .../src/common/stores/entryCopyStore.ts | 11 ++ apps/client/src/common/utils/deviceUtils.ts | 2 + .../cuesheet-table-elements/EditableCell.tsx | 19 +- apps/client/src/features/rundown/Rundown.tsx | 179 +++++++++--------- .../rundown/common/EditableBlockTitle.tsx | 7 +- .../rundown/event-editor/EventEditor.tsx | 7 +- .../event-editor/EventEditorEmpty.module.scss | 34 ++++ .../rundown/event-editor/EventEditorEmpty.tsx | 102 ++++++++++ .../event-editor/composite/EventTextArea.tsx | 9 +- .../event-editor/composite/EventTextInput.tsx | 7 +- apps/client/src/theme/theme.ts | 8 + packages/utils/index.ts | 1 + .../src/rundown-utils/rundownUtils.test.ts | 75 ++++++-- .../utils/src/rundown-utils/rundownUtils.ts | 75 ++++---- 19 files changed, 424 insertions(+), 253 deletions(-) delete mode 100644 apps/client/src/common/components/input/text-input/TextInput.tsx create mode 100644 apps/client/src/common/stores/entryCopyStore.ts create mode 100644 apps/client/src/features/rundown/event-editor/EventEditorEmpty.module.scss create mode 100644 apps/client/src/features/rundown/event-editor/EventEditorEmpty.tsx diff --git a/apps/client/src/common/components/input/auto-text-area/AutoTextArea.tsx b/apps/client/src/common/components/input/auto-text-area/AutoTextArea.tsx index 1e47b8a84..9fc23c8ed 100644 --- a/apps/client/src/common/components/input/auto-text-area/AutoTextArea.tsx +++ b/apps/client/src/common/components/input/auto-text-area/AutoTextArea.tsx @@ -1,27 +1,25 @@ -import { useEffect, useRef } from 'react'; +import { RefObject, useEffect } from 'react'; import { Textarea, TextareaProps } from '@chakra-ui/react'; // @ts-expect-error no types from library import autosize from 'autosize/dist/autosize'; -export const AutoTextArea = (props: TextareaProps) => { - const { value } = props; - - const ref = useRef(null); +export const AutoTextArea = (props: TextareaProps & { inputref: RefObject }) => { + const { value, inputref } = props; useEffect(() => { - const node = ref.current; - autosize(ref.current); + const node = inputref.current; + autosize(inputref.current); return () => { autosize.destroy(node); }; - }, [value]); + }, [inputref, value]); return (