Update toolbox-search to search dropdown field options
Check for duplicates
- [X] I have searched for similar issues before opening a new one.
Component
toolbox-search
Problem
No response
Request
The toolbox-search plugin should include the text of options in dropdown fields when filtering blocks. Right now, only the label text on the block (or the contents of text fields) are included in the index. Ideally, the matching option would also be shown pre-selected on the block in the toolbox.
Alternatives considered
No response
Additional context
No response
To work on this bug:
- Run
npm installat the root of the repository to install all parts ofblockly-samples cdtoplugins/toolbox-search- Run
npm run startto open a playground and verify that the toolbox search plugin works for you - Make code changes (see below)
- Verify that the changes work in the playground as expected
The code that searches block text is in indexBlocks in src/block_searcher.ts. Lines 31-32 loop over every filed and call indexBlockText(field.getText()).
- Update this call to check if the field is a dropdown, and call
indexBlockTextfor every option in the dropdown menu. - Update
matchBlocksinsrc/toolbox_search.tsto set the value of the dropdown based on the query, if it doesn't match the default text on the block.
To verify, find a block with a dropdown (such as one of the math blocks) and do a search for a non-default value that is contained in the dropdown.
https://github.com/sammitako and I have been working on this during the GHC OSD and would like to continue on finishing it. Can we both get assigned to this issue? Thanks!
I think I have to tag @sammitako in order to assign to her. Let's see if this works.
Thank you!
Work still to be done: Select the proper option in the dropdown when searching.