Improve select prompt (with search)
See original GitHub issueHi,
I’ve finally found the time to experiment with the select prompt with auto-complete and here is the feedback.
Ctrl-C keeps the console dirty
When someone ctrl-c’s instead of validating the prompt, the options stay displayed and clutter the terminal.
If it is possible, it’d be nice to catch the SIGINT signal and cleanup.
Less-strict search method
The current search method shows a few improvement opportunities IMO:
- it currently only matches the values. This has the drawback that when searching in options with names, the values are not displayed and may not share a single character in common with the values (ex:
{name: 'Blue', value: '#0000AA'}
). - is searches at the beginning of the value and not everywhere (meaning
new
does not matchAdd a new feature
).
I think it would be better to search on names when provided and to use a case-insensitive-match-anywhere search method.
Something like:
function searchMethod (allOptions, searchText) {
return allOptions
.filter(option => !option.disabled)
.reduce(
(seed, option) => {
const lowerCaseName = option.name.toLocaleLowerCase();
const lowerCaseValue = option.value.toLocaleLowerCase();
const lowerCaseSearch = searchText.toLocaleLowerCase();
const matchesPerfectly = lowerCaseName === lowerCaseSearch || lowerCaseValue === lowerCaseSearch;
if (matchesPerfectly) { // Put perfect match first!
return [ option, ...seed ];
}
const matches = lowerCaseName.includes(lowerCaseSearch) || lowerCaseValue.includes(lowerCaseSearch);
return matches ? [ ...seed, option ] : seed;
},
[],
);
}
WDYT?
I can help with implementation if you want to take these, and can split issues etc… 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to resize Select and Search or Value prompts to ... - IBM
Multi-select Search&Select prompts have two fields, both of which must be widened. Steps 1 and 2 will widen the right-side prompt. Add the ......
Read more >Tips and Tricks: Add a Select and Search Prompt to a Report ...
One of the missing features with Data Modules is the ability to use a Select & Search (search and select?) prompt in Cognos...
Read more >Advanced Select and Search Prompts - CognosPaul
So I was asked to find a way to shrink it down. SnS hogging the page. Obviously the solution was to everything but...
Read more >Is there any way to increase the size of select & search prompt
Hi All, I have a select & search prompt in my prompt page. The values loaded in this prompt are of charecters with...
Read more >increasing the width of a search and select prompt
I managed to increase the width of the window where the search results are displayed using javascript. Does anyone know how to.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Noice! I’ve tested it and it works on commit
a6b5d36
thanks 😃@quilicicf the issue with the stdout should be fixed now. i realized, there was realy no logic for clearing the stdout. i think, it was just my zsh and docker which cleared the stdout automatically. With the bash shell i got the same issue.