blockly-samples icon indicating copy to clipboard operation
blockly-samples copied to clipboard

Include non-block (button) toolbox items in toolbox-search

Open gonfunko opened this issue 2 years ago • 6 comments

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 currently only indexes blocks. It should also index and search flyout buttons, e.g. the Create Variable button should be shown in the toolbox when searching for "variable".

Alternatives considered

No response

Additional context

No response

gonfunko avatar Sep 20 '23 19:09 gonfunko

To work on this bug:

  • Run npm install at the root of the repository to install all parts of blockly-samples
  • cd to plugins/toolbox-search
  • Run npm run start to 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 indexes blocks is initBlockSearcher in src/toolbox_search.ts. It calls getAvailableBlocks to check toolbox definitions for blocks.

  • A similar function needs to be created to look for buttons, which have kind button, and it then needs to be wired into search in a similar way to blocks.
  • matchBlocks needs to be updated to add buttons into the toolbox, instead of just blocks.

To test, check that you get the Create Variable button when searching "variable", and check that clicking it actually creates a variable.

rachel-fenichel avatar Sep 22 '23 18:09 rachel-fenichel

hi! I would like to work on this issue

firangizg avatar Sep 22 '23 20:09 firangizg

Heya @firangizg We have limited issues for the second session, so we're planning on having people work in groups! If you're still interested in that, you can join our call in ~20 minutes and we'll give y'all more info =)

BeksOmega avatar Sep 22 '23 20:09 BeksOmega

Image

Hi team, I am working on this issue. I found out there is no buttons when searching in this.workspace_.options.languageTree.contents, there are only blocks. Therefore, buttons are unsearchable. How should I fix this? Thanks!

Xiyu-Serena-Wan avatar Oct 14 '23 23:10 Xiyu-Serena-Wan

I am a GHC OSD afternoon session attendee and I am still working on this issue.

Xiyu-Serena-Wan avatar Oct 14 '23 23:10 Xiyu-Serena-Wan

Hi team, I am working on this issue. I found out there is no buttons when searching in this.workspace_.options.languageTree.contents, there are only blocks. Therefore, buttons are unsearchable. How should I fix this? Thanks!

Hello,

Currently dynamic categories aren't being searched, and all of the buttons in the default toolbox exist as part of dynamic categories.

If you create a test toolbox with buttons in it that are not part of dynamic categories, then the buttons will be in the languageTree.contents. So I would recommend creating your own test toolbox on the test page and testing against that! Here are the docs for defining a toolbox.

I hope that helps! If you have any further questions please reply! --Beka

BeksOmega avatar Oct 16 '23 16:10 BeksOmega