From 145d94a49f5fa6b18a6d2502f52158d15137914a Mon Sep 17 00:00:00 2001 From: BrianHung Date: Fri, 8 Mar 2024 15:59:39 -0800 Subject: [PATCH 1/3] use readonly for growing entry and number overlay --- packages/core/src/cells/number-cell.tsx | 2 +- packages/core/src/cells/row-id-cell.tsx | 2 +- packages/core/src/cells/text-cell.tsx | 2 +- .../data-grid-overlay-editor/private/number-overlay-editor.tsx | 3 +++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/core/src/cells/number-cell.tsx b/packages/core/src/cells/number-cell.tsx index fd7d37260..9592506ac 100644 --- a/packages/core/src/cells/number-cell.tsx +++ b/packages/core/src/cells/number-cell.tsx @@ -27,7 +27,7 @@ export const numberCellRenderer: InternalCellRenderer = { = { diff --git a/packages/core/src/cells/text-cell.tsx b/packages/core/src/cells/text-cell.tsx index ce3a081ab..0e44ab7bb 100644 --- a/packages/core/src/cells/text-cell.tsx +++ b/packages/core/src/cells/text-cell.tsx @@ -71,7 +71,7 @@ export const textCellRenderer: InternalCellRenderer = { style={cell.allowWrapping === true ? { padding: "3px 8.5px" } : undefined} highlight={isHighlighted} autoFocus={value.readonly !== true} - disabled={value.readonly === true} + readOnly={value.readonly === true} altNewline={true} value={value.data} validatedSelection={validatedSelection} diff --git a/packages/core/src/internal/data-grid-overlay-editor/private/number-overlay-editor.tsx b/packages/core/src/internal/data-grid-overlay-editor/private/number-overlay-editor.tsx index 4a539916f..00fa7c7ee 100644 --- a/packages/core/src/internal/data-grid-overlay-editor/private/number-overlay-editor.tsx +++ b/packages/core/src/internal/data-grid-overlay-editor/private/number-overlay-editor.tsx @@ -7,6 +7,7 @@ import type { NumberFormatValues } from "react-number-format/types/types.js"; interface Props { readonly value: number | undefined; readonly disabled?: boolean; + readonly readOnly?: boolean; readonly onChange: (values: NumberFormatValues) => void; readonly highlight: boolean; readonly validatedSelection?: SelectionRange; @@ -34,6 +35,7 @@ const NumberOverlayEditor: React.FunctionComponent = p => { value, onChange, disabled, + readOnly, highlight, validatedSelection, fixedDecimals, @@ -61,6 +63,7 @@ const NumberOverlayEditor: React.FunctionComponent = p => { e.target.setSelectionRange(highlight ? 0 : e.target.value.length, e.target.value.length) } disabled={disabled === true} + readOnly={readOnly === true} decimalScale={fixedDecimals} allowNegative={allowNegative} thousandSeparator={thousandSeparator ?? getThousandSeprator()} From 48d9645b69e7144b32c96731daf97c0e4a7f984f Mon Sep 17 00:00:00 2001 From: BrianHung Date: Fri, 8 Mar 2024 16:00:16 -0800 Subject: [PATCH 2/3] autofocus overlay editor on mount --- .../data-grid-overlay-editor.tsx | 12 +++++++++--- .../private/bubbles-overlay-editor.tsx | 1 - .../private/markdown-overlay-editor.tsx | 1 - .../private/uri-overlay-editor.tsx | 1 - 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/core/src/internal/data-grid-overlay-editor/data-grid-overlay-editor.tsx b/packages/core/src/internal/data-grid-overlay-editor/data-grid-overlay-editor.tsx index 28850bcbc..0c1e605c5 100644 --- a/packages/core/src/internal/data-grid-overlay-editor/data-grid-overlay-editor.tsx +++ b/packages/core/src/internal/data-grid-overlay-editor/data-grid-overlay-editor.tsx @@ -220,7 +220,10 @@ const DataGridOverlayEditor: React.FunctionComponent onClickOutside={onClickOutside} isOutsideClick={isOutsideClick}> { + ref(elem); + if (elem) elem.focus(); + }} id={id} className={classWrap} style={styleOverride} @@ -228,8 +231,11 @@ const DataGridOverlayEditor: React.FunctionComponent targetX={target.x - bloomX} targetY={target.y - bloomY} targetWidth={target.width + bloomX * 2} - targetHeight={target.height + bloomY * 2}> -
+ targetHeight={target.height + bloomY * 2} + tabIndex={-1} + onKeyDown={onKeyDown} + > +
{editor}
diff --git a/packages/core/src/internal/data-grid-overlay-editor/private/bubbles-overlay-editor.tsx b/packages/core/src/internal/data-grid-overlay-editor/private/bubbles-overlay-editor.tsx index 6fefcd931..bfcdcf22f 100644 --- a/packages/core/src/internal/data-grid-overlay-editor/private/bubbles-overlay-editor.tsx +++ b/packages/core/src/internal/data-grid-overlay-editor/private/bubbles-overlay-editor.tsx @@ -14,7 +14,6 @@ const BubblesOverlayEditor: React.FunctionComponent = p => { {b}
))} -