diff --git a/tgui/docs/component-reference.md b/tgui/docs/component-reference.md index 87b8198bf72..653d9defc68 100644 --- a/tgui/docs/component-reference.md +++ b/tgui/docs/component-reference.md @@ -552,9 +552,10 @@ A basic text input, which allow users to enter text into a UI. - `fluid: boolean` - Fill all available horizontal space. - `selfClear: boolean` - Clear after hitting enter, as well as remain focused when this happens. Useful for things like chat inputs. -- `onChange: (e, value) => void` - Fires when the value is changed. +- `onChange: (e, value) => void` - Fires when the user clicks out or presses enter. - `onEnter: (e, value) => void` - Fires when the user hits enter. -- `onEscape: (e, value) => void` - Fires when the user hits escape. +- `onEscape: (e) => void` - Fires when the user hits escape. +- `onInput: (e, value) => void` - Fires when the user types into the input. ### `Knob` diff --git a/tgui/packages/tgui/components/Input.tsx b/tgui/packages/tgui/components/Input.tsx index d10cd657f13..d9ecf31e908 100644 --- a/tgui/packages/tgui/components/Input.tsx +++ b/tgui/packages/tgui/components/Input.tsx @@ -17,12 +17,14 @@ type Props = Partial<{ fluid: boolean; maxLength: number; monospace: boolean; - // Fires when: Value changes + /** Fires when user is 'done typing': Clicked out, blur, enter key */ onChange: (event: SyntheticEvent, value: string) => void; - // Fires when: Pressed enter without shift + /** Fires once the enter key is pressed */ onEnter: (event: SyntheticEvent, value: string) => void; - // Fires when: Pressed escape + /** Fires once the escape key is pressed */ onEscape: (event: SyntheticEvent) => void; + /** Fires on each key press / value change. Used for searching */ + onInput: (event: SyntheticEvent, value: string) => void; placeholder: string; selfClear: boolean; value: string | number; @@ -57,6 +59,7 @@ export const Input = (props: Props) => { event.currentTarget.value = ''; } else { event.currentTarget.blur(); + onChange?.(event, event.currentTarget.value); } return; @@ -102,7 +105,8 @@ export const Input = (props: Props) => { onChange?.(event, event.target.value)} + onBlur={(event) => onChange?.(event, event.target.value)} + onChange={(event) => onInput?.(event, event.target.value)} onKeyDown={handleKeyDown} placeholder={placeholder} ref={inputRef} diff --git a/tgui/packages/tgui/interfaces/Cargo.jsx b/tgui/packages/tgui/interfaces/Cargo.jsx index 045cdd13277..f160970bc51 100644 --- a/tgui/packages/tgui/interfaces/Cargo.jsx +++ b/tgui/packages/tgui/interfaces/Cargo.jsx @@ -235,7 +235,7 @@ export const CargoCatalog = (props) => { fluid placeholder="Search..." value={searchText} - onChange={(e, value) => { + onInput={(e, value) => { if (value === searchText) { return; } diff --git a/tgui/packages/tgui/interfaces/CellularEmporium.tsx b/tgui/packages/tgui/interfaces/CellularEmporium.tsx index 2573b46c6e1..c8ef86460c0 100644 --- a/tgui/packages/tgui/interfaces/CellularEmporium.tsx +++ b/tgui/packages/tgui/interfaces/CellularEmporium.tsx @@ -71,7 +71,7 @@ export const CellularEmporium = (props) => { setSearchAbilities(value)} + onInput={(event, value) => setSearchAbilities(value)} placeholder="Search Abilities..." value={searchAbilities} /> diff --git a/tgui/packages/tgui/interfaces/CheckboxInput.tsx b/tgui/packages/tgui/interfaces/CheckboxInput.tsx index 4e0f088678b..0d29afd3dfa 100644 --- a/tgui/packages/tgui/interfaces/CheckboxInput.tsx +++ b/tgui/packages/tgui/interfaces/CheckboxInput.tsx @@ -99,7 +99,7 @@ export const CheckboxInput = (props) => { setSearchQuery(value)} + onInput={(_, value) => setSearchQuery(value)} /> diff --git a/tgui/packages/tgui/interfaces/Fabrication/SearchBar.tsx b/tgui/packages/tgui/interfaces/Fabrication/SearchBar.tsx index 27b697a9678..8afc95acc03 100644 --- a/tgui/packages/tgui/interfaces/Fabrication/SearchBar.tsx +++ b/tgui/packages/tgui/interfaces/Fabrication/SearchBar.tsx @@ -45,7 +45,7 @@ export class SearchBar extends Component { this.onInput(v)} + onInput={(_e: unknown, v: string) => this.onInput(v)} value={searchText} /> diff --git a/tgui/packages/tgui/interfaces/ForceEvent.tsx b/tgui/packages/tgui/interfaces/ForceEvent.tsx index cd91214247c..a93ea6a5f43 100644 --- a/tgui/packages/tgui/interfaces/ForceEvent.tsx +++ b/tgui/packages/tgui/interfaces/ForceEvent.tsx @@ -94,7 +94,7 @@ export const PanelOptions = (props) => { setSearchQuery(value)} + onInput={(e, value) => setSearchQuery(value)} placeholder="Search..." value={searchQuery} /> diff --git a/tgui/packages/tgui/interfaces/ListInputModal.tsx b/tgui/packages/tgui/interfaces/ListInputModal.tsx index f3f871b65b8..3048d1cdbe1 100644 --- a/tgui/packages/tgui/interfaces/ListInputModal.tsx +++ b/tgui/packages/tgui/interfaces/ListInputModal.tsx @@ -246,7 +246,7 @@ const SearchBar = (props) => { event.preventDefault(); act('submit', { entry: filteredItems[selected] }); }} - onChange={(_, value) => onSearch(value)} + onInput={(_, value) => onSearch(value)} placeholder="Search..." value={searchQuery} /> diff --git a/tgui/packages/tgui/interfaces/LogViewer.tsx b/tgui/packages/tgui/interfaces/LogViewer.tsx index be8aa1c073c..be1ff09aee0 100644 --- a/tgui/packages/tgui/interfaces/LogViewer.tsx +++ b/tgui/packages/tgui/interfaces/LogViewer.tsx @@ -181,7 +181,7 @@ const CategoryViewer = (props: CategoryViewerProps) => { fill placeholder="Search" value={search} - onChange={(_, value) => setSearch(value)} + onInput={(_, value) => setSearch(value)} />