From dd06a11d99e08e99cee8c92aa594213ddf790942 Mon Sep 17 00:00:00 2001 From: Martin Vladic Date: Wed, 9 Oct 2024 14:05:27 +0200 Subject: [PATCH] #572 --- .../_stylesheets/project-editor.less | 6 ++---- packages/eez-studio-ui/search-input.tsx | 6 ++++++ .../PropertyGrid/ObjectReferenceInput.tsx | 18 +++++++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/eez-studio-ui/_stylesheets/project-editor.less b/packages/eez-studio-ui/_stylesheets/project-editor.less index 43aec539..9b037ca4 100644 --- a/packages/eez-studio-ui/_stylesheets/project-editor.less +++ b/packages/eez-studio-ui/_stylesheets/project-editor.less @@ -520,10 +520,8 @@ border-radius: 4px; overflow: hidden; - div:nth-child(1) { - .EezStudio_SearchInput { - border-bottom: 1px solid @borderColor; - } + .EezStudio_SearchInput_Container { + border-bottom: 1px solid @borderColor; } div:nth-child(2) { diff --git a/packages/eez-studio-ui/search-input.tsx b/packages/eez-studio-ui/search-input.tsx index 5d66cfd1..4b723ea0 100644 --- a/packages/eez-studio-ui/search-input.tsx +++ b/packages/eez-studio-ui/search-input.tsx @@ -7,6 +7,7 @@ export class SearchInput extends React.Component<{ onChange: (event: React.ChangeEvent) => void; onKeyDown?: (event: React.KeyboardEvent) => void; onClear: () => void; + disableSpellcheck?: boolean; }> { render() { return ( @@ -20,6 +21,11 @@ export class SearchInput extends React.Component<{ value={this.props.searchText} onChange={this.props.onChange} onKeyDown={this.props.onKeyDown} + spellCheck={ + this.props.disableSpellcheck === true + ? false + : undefined + } /> {this.props.searchText && ( enumItem.id - ); + return getEnumItems(this.props.objects, propertyInfo) + .filter( + enumItem => + (enumItem.label || enumItem.id.toString()) + .toLowerCase() + .indexOf( + this.searchText.trim().toLowerCase() + ) != -1 + ) + .map(enumItem => enumItem.id); } return []; } @@ -83,7 +90,7 @@ export const ObjectReferenceInput = observer( !this.searchText || objectName .toLowerCase() - .indexOf(this.searchText.toLowerCase()) != -1 + .indexOf(this.searchText.trim().toLowerCase()) != -1 ) .sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase())); } @@ -93,7 +100,7 @@ export const ObjectReferenceInput = observer( }; onSearchChange(event: any) { - this.searchText = ($(event.target).val() as string).trim(); + this.searchText = $(event.target).val() as string; } setDropDownOpen(open: boolean) { @@ -196,6 +203,7 @@ export const ObjectReferenceInput = observer( })} onChange={this.onSearchChange} onKeyDown={this.onSearchChange} + disableSpellcheck={true} />