Files
ontime/apps/client/src/views/cuesheet/cuesheet-table-elements/MultiLineCell.tsx
T
Alex Christoffer Rasmussen b048d0f88d Edit in cuesheet (#1372)
* pass on all event edits

* MakePublic

* trim value in cell

* edit notes

* title

* add key check

* don't log error

Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>

* checkbox

* refactor

* remove log

* fix test

* use row number to test value

---------

Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>
2024-12-16 14:27:25 +01:00

38 lines
1.1 KiB
TypeScript

import { memo, useCallback, useRef } from 'react';
import { AutoTextArea } from '../../../common/components/input/auto-text-area/AutoTextArea';
import useReactiveTextInput from '../../../common/components/input/text-input/useReactiveTextInput';
interface MultiLineCellProps {
initialValue: string;
handleUpdate: (newValue: string) => void;
}
const MultiLineCell = (props: MultiLineCellProps) => {
const { initialValue, handleUpdate } = props;
const ref = useRef<HTMLInputElement | null>(null);
const submitCallback = useCallback((newValue: string) => handleUpdate(newValue), [handleUpdate]);
const { value, onChange, onBlur, onKeyDown } = useReactiveTextInput(initialValue, submitCallback, ref, {
submitOnCtrlEnter: true,
});
return (
<AutoTextArea
inputref={ref}
rows={1}
size='sm'
style={{ padding: 0 }}
transition='none'
variant='ontime-transparent'
value={value}
onChange={onChange}
onBlur={onBlur}
onKeyDown={onKeyDown}
spellCheck={false}
/>
);
};
export default memo(MultiLineCell);