mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 02:13:48 +00:00
b048d0f88d
* 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>
38 lines
1.1 KiB
TypeScript
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);
|