Skip to content

Commit

Permalink
Merge pull request #305 from FluxNotes/context-search-fix
Browse files Browse the repository at this point in the history
Fixed bug where search bar would disappear if returned no results
  • Loading branch information
nicoleng12 authored Mar 29, 2018
2 parents e6cc2f2 + efa7551 commit 99f7c51
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/context/ContextOptions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class ContextOptions extends Component {
super(props);

this.state = {
searchString: "",
searchString: '',
tooltipVisibility: 'visible'
}
}
Expand Down Expand Up @@ -51,13 +51,15 @@ export default class ContextOptions extends Component {
count++;
});
});
const countBeforeSearch = count;

// enable filter?
const showFilter = (count > 10);

// build our list of filtered triggers (only filter if we will be showing search bar)
let triggers = [];
count = 0;

validShortcuts.forEach((shortcut, i) => {
let groupName = this.props.shortcutManager.getShortcutGroupName(shortcut);
this.props.shortcutManager.getTriggersForShortcut(shortcut, context).forEach((trigger, j) => {
Expand Down Expand Up @@ -90,7 +92,7 @@ export default class ContextOptions extends Component {
}
});

if (totalShown === 0) {
if (!showFilter && totalShown === 0) {
return null;
}

Expand All @@ -102,7 +104,7 @@ export default class ContextOptions extends Component {
<div className="shortcut-search-container">
<div className="shortcut-search-title">
<div>Filter:</div>
<div className="count">(showing {totalShown} of {count})</div>
<div className="count">(showing {totalShown} of {countBeforeSearch})</div>
</div>

<TextField
Expand Down

0 comments on commit 99f7c51

Please sign in to comment.