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

fix: Implement alternative highlighting scheme for search

Open ewpatton opened this issue 6 months ago • 1 comments

Change-Id: Ifcee0a5a30374b0d1e72a24c6c6d538dba16e58f

The basics

The details

Resolves

As discussed at the Blockly Summit, the highlighting behavior of the workspace-search plugin could be improved. This is one attempt at that. It might be worth further tweaking of the CSS attributes.

Proposed Changes

This PR updates the workspace search plugin to desaturate non-matching blocks while supersaturating the selected block to draw more focus to the selection rather than turning the actively highlighted block black. The currently focused block gets saturation +50%, other matching blocks get saturation -50%, and non-matching blocks are completely desaturated.

image

Reason for Changes

Test Coverage

Because changing the coloring logic needed to move the CSS classes around, I updated the test logic for detecting whether a block is actively in the search set.

Documentation

For developers looking to change the behavior, we may want to document how they override the CSS rules defined in plugins/workspace-search/src/css.ts. Anyone overriding the existing CSS rules will need to update their definitions.

Additional Information

ewpatton avatar Jun 04 '25 21:06 ewpatton

I should note I tried using setHighlighted(true) but this didn't seem to work. It's unclear whether this is an interact with the new CSS styles or whether it's an issue in the setHighlighted function itself.

ewpatton avatar Jun 04 '25 22:06 ewpatton