Don't clear searchValue on CommandDialog onBlur (#3172)

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-07-06 11:01:11 +03:00
1 parent 8ac3203924
commit b2836eb57a
1 file changed
+16 -5
@@ -35,16 +35,17 @@ import { clusterViewURL } from "../../../common/routes";
@observer @observer
export class CommandDialog extends React.Component { export class CommandDialog extends React.Component {
@observable menuIsOpen = true; @observable menuIsOpen = true;
@observable searchValue: any = undefined;
constructor(props: {}) { constructor(props: {}) {
super(props); super(props);
makeObservable(this); makeObservable(this);
} }
@computed get activeEntity(): CatalogEntity | undefined { @computed get activeEntity(): CatalogEntity | undefined {
return catalogEntityRegistry.activeEntity; return catalogEntityRegistry.activeEntity;
} }
@computed get options() { @computed get options() {
const registry = CommandRegistry.getInstance(); const registry = CommandRegistry.getInstance();
@@ -104,14 +105,24 @@ export class CommandDialog extends React.Component {
return ( return (
<Select <Select
menuPortalTarget={null} menuPortalTarget={null}
onChange={(v) => this.onChange(v.value)} onChange={v => this.onChange(v.value)}
components={{ DropdownIndicator: null, IndicatorSeparator: null }} components={{
DropdownIndicator: null,
IndicatorSeparator: null,
}}
menuIsOpen={this.menuIsOpen} menuIsOpen={this.menuIsOpen}
options={this.options} options={this.options}
autoFocus={true} autoFocus={true}
escapeClearsValue={false} escapeClearsValue={false}
data-test-id="command-palette-search" data-test-id="command-palette-search"
placeholder="Type a command or search&hellip;" /> placeholder="Type a command or search&hellip;"
onInputChange={(newValue, { action }) => {
if (action === "input-change") {
this.searchValue = newValue;
}
}}
inputValue={this.searchValue}
/>
); );
} }
} }