mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-14 04:19:22 +03:00
parent
a2adf7359d
commit
1f6f1fcd53
@ -58,7 +58,7 @@ export class Omnibox extends Component {
|
||||
control(evt) {
|
||||
if (evt.key === 'Escape') {
|
||||
if (this.state.query.length > 0) {
|
||||
this.setState({ query: '', results: this.initialResults() });
|
||||
this.setState({ query: '', results: this.initialResults(), selected: [] });
|
||||
} else if (this.props.show) {
|
||||
this.props.api.local.setOmnibox();
|
||||
}
|
||||
@ -78,8 +78,10 @@ export class Omnibox extends Component {
|
||||
|
||||
if (evt.key === 'Enter') {
|
||||
evt.preventDefault();
|
||||
if (this.state.selected !== []) {
|
||||
if (this.state.selected.length > 0) {
|
||||
this.navigate(this.state.selected[0], this.state.selected[1]);
|
||||
} else if (Array.from(this.state.results.values()).flat().length === 0) {
|
||||
return;
|
||||
} else {
|
||||
this.navigate(
|
||||
Array.from(this.state.results.values()).flat()[0].app,
|
||||
@ -90,7 +92,7 @@ export class Omnibox extends Component {
|
||||
|
||||
handleClickOutside(evt) {
|
||||
if (this.props.show && !this.omniBox.contains(evt.target)) {
|
||||
this.setState({ results: this.initialResults(), query: '' }, () => {
|
||||
this.setState({ results: this.initialResults(), query: '', selected: [] }, () => {
|
||||
this.props.api.local.setOmnibox();
|
||||
});
|
||||
}
|
||||
@ -158,9 +160,9 @@ export class Omnibox extends Component {
|
||||
);
|
||||
});
|
||||
|
||||
const flattenedResultLinks = Array.from(results.values()).flat().map(result => result.link);
|
||||
const flattenedResultLinks = Array.from(results.values()).flat().map(result => [result.app, result.link]);
|
||||
if (!flattenedResultLinks.includes(selected)) {
|
||||
selected = flattenedResultLinks[0];
|
||||
selected = flattenedResultLinks[0] || [];
|
||||
}
|
||||
|
||||
this.setState({ results, selected });
|
||||
|
Loading…
Reference in New Issue
Block a user