mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 21:24:11 +00:00
feat: add table navigation to cuesheet table (#1483)
* refactor: cuesheet table body * feat: add table navigation
This commit is contained in:
committed by
Carlos Valente
parent
8465b04c89
commit
e5b30770ce
+18
-6
@@ -1,22 +1,34 @@
|
||||
import { HTMLAttributes, memo, PropsWithChildren } from 'react';
|
||||
import { forwardRef, HTMLAttributes, memo, PropsWithChildren, useImperativeHandle, useRef } from 'react';
|
||||
|
||||
import { cx } from '../../../../common/utils/styleUtils';
|
||||
|
||||
import style from './TextLikeInput.module.scss';
|
||||
|
||||
export default memo(TextLikeInput);
|
||||
|
||||
interface TextLikeInputProps extends HTMLAttributes<HTMLSpanElement> {
|
||||
delayed?: boolean;
|
||||
muted?: boolean;
|
||||
}
|
||||
|
||||
function TextLikeInput(props: PropsWithChildren<TextLikeInputProps>) {
|
||||
const TextLikeInput = forwardRef((props: PropsWithChildren<TextLikeInputProps>, textRef) => {
|
||||
const { delayed, muted, children, className, ...elementProps } = props;
|
||||
const ref = useRef<HTMLDivElement | null>(null);
|
||||
const classes = cx([style.textInput, delayed && style.delayed, muted && style.muted, className]);
|
||||
|
||||
useImperativeHandle(textRef, () => {
|
||||
return {
|
||||
focusParentElement() {
|
||||
ref.current?.parentElement?.focus();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<div className={classes} {...elementProps} tabIndex={0}>
|
||||
<div className={classes} {...elementProps} tabIndex={0} ref={ref}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
TextLikeInput.displayName = 'TextLikeInput';
|
||||
|
||||
export default memo(TextLikeInput);
|
||||
|
||||
Reference in New Issue
Block a user