From 42fea7bf7daa963298e2d9d0592b63c44eaed611 Mon Sep 17 00:00:00 2001 From: Tony Zhou Date: Mon, 20 Mar 2023 10:17:11 -0400 Subject: [PATCH 1/5] fix --- packages/components/src/DateTimeInput.tsx | 11 ++++++++++- packages/components/src/MaskedInput.tsx | 9 +++++++-- packages/iris-grid/src/GotoRow.tsx | 5 +++++ packages/iris-grid/src/IrisGrid.tsx | 6 ++++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/components/src/DateTimeInput.tsx b/packages/components/src/DateTimeInput.tsx index 154e4fd718..5d3a76bbdd 100644 --- a/packages/components/src/DateTimeInput.tsx +++ b/packages/components/src/DateTimeInput.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useState } from 'react'; +import React, { KeyboardEvent, useCallback, useState } from 'react'; import classNames from 'classnames'; import Log from '@deephaven/log'; import MaskedInput, { SelectionSegment } from './MaskedInput'; @@ -23,6 +23,7 @@ type DateTimeInputProps = { defaultValue?: string; onFocus?(): void; onBlur?(): void; + onSubmit?(event?: KeyboardEvent): void; 'data-testid'?: string; }; @@ -54,6 +55,7 @@ const DateTimeInput = React.forwardRef( defaultValue = '', onFocus = () => undefined, onBlur = () => undefined, + onSubmit, 'data-testid': dataTestId, } = props; const [value, setValue] = useState( @@ -61,6 +63,12 @@ const DateTimeInput = React.forwardRef( ); const [selection, setSelection] = useState(); + const handleSubmit = useCallback( + (event: KeyboardEvent): void => { + onSubmit?.(event); + }, + [onSubmit] + ); const handleChange = useCallback( (newValue: string): void => { log.debug('handleChange', newValue); @@ -90,6 +98,7 @@ const DateTimeInput = React.forwardRef( getNextSegmentValue={getNextSegmentValue} onChange={handleChange} onSelect={setSelection} + onSubmit={handleSubmit} pattern={FULL_DATE_PATTERN} placeholder={FULL_DATE_FORMAT} selection={selection} diff --git a/packages/components/src/MaskedInput.tsx b/packages/components/src/MaskedInput.tsx index 24183ac814..3e5b68007c 100644 --- a/packages/components/src/MaskedInput.tsx +++ b/packages/components/src/MaskedInput.tsx @@ -1,4 +1,4 @@ -import React, { useMemo, useEffect, useCallback } from 'react'; +import React, { useMemo, useEffect, useCallback, KeyboardEvent } from 'react'; import classNames from 'classnames'; import Log from '@deephaven/log'; import { useForwardedRef } from '@deephaven/react-hooks'; @@ -88,6 +88,8 @@ type MaskedInputProps = { onChange?(value: string): void; /** Called when selection changes */ onSelect?(segment: SelectionSegment): void; + /** Called when enter is pressed */ + onSubmit?(event?: KeyboardEvent): void; /** Retrieve the next value for a provided segment */ getNextSegmentValue?( segment: SelectionSegment, @@ -124,6 +126,7 @@ const MaskedInput = React.forwardRef( getPreferredReplacementString = DEFAULT_GET_PREFERRED_REPLACEMENT_STRING, onChange = () => false, onSelect = () => false, + onSubmit, pattern, placeholder, selection, @@ -428,7 +431,9 @@ const MaskedInput = React.forwardRef( ); return; } - + if (key === 'Enter') { + onSubmit?.(event); + } if (key.startsWith('Arrow')) { handleArrowKey(event); return; diff --git a/packages/iris-grid/src/GotoRow.tsx b/packages/iris-grid/src/GotoRow.tsx index 9ea5e63b4b..af8311ed9d 100644 --- a/packages/iris-grid/src/GotoRow.tsx +++ b/packages/iris-grid/src/GotoRow.tsx @@ -46,6 +46,7 @@ interface GotoRowProps { gotoValueSelectedColumnName: ColumnName; gotoValue: string; + gotoValueFilter: FilterTypeValue; onGotoValueSelectedColumnNameChanged: (columnName: ColumnName) => void; onGotoValueSelectedFilterChanged: (filter: FilterTypeValue) => void; onGotoValueChanged: (input: string) => void; @@ -67,6 +68,7 @@ function GotoRow({ onClose, gotoValueSelectedColumnName, gotoValue, + gotoValueFilter, onGotoValueSelectedColumnNameChanged, onGotoValueSelectedFilterChanged, onGotoValueChanged, @@ -163,6 +165,7 @@ function GotoRow({ return (
); @@ -186,6 +190,7 @@ function GotoRow({ event.target.value as FilterTypeValue ); }} + value={gotoValueFilter} >