Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 9, 2024
1 parent 9c4b966 commit dd06a11
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
6 changes: 2 additions & 4 deletions packages/eez-studio-ui/_stylesheets/project-editor.less
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions packages/eez-studio-ui/search-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export class SearchInput extends React.Component<{
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
onClear: () => void;
disableSpellcheck?: boolean;
}> {
render() {
return (
Expand All @@ -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 && (
<IconAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,16 @@ export const ObjectReferenceInput = observer(

if (!propertyInfo.referencedObjectCollectionPath) {
if (propertyInfo.enumItems) {
return getEnumItems(this.props.objects, propertyInfo).map(
enumItem => 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 [];
}
Expand All @@ -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()));
}
Expand All @@ -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) {
Expand Down Expand Up @@ -196,6 +203,7 @@ export const ObjectReferenceInput = observer(
})}
onChange={this.onSearchChange}
onKeyDown={this.onSearchChange}
disableSpellcheck={true}
/>
</div>
<div>
Expand Down

0 comments on commit dd06a11

Please sign in to comment.