Skip to content

[Bug] Toolbox brush icon "Clear Selections" stays highlighted after being clicked #21771

Description

@noodleslove

Version

6.1.0

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?code=PYBwLglsB2AEC8sDeAoWszGAGwEbAA8AuZNdWCMAUwFsBlCALypICYAGAGjPQHpfYAOWAAnGgENsFAMYwAziQAm4kQGtYAcxHiAngDpYACQgaAFthOnqimfJKjx0DVT09b0OmB3YWyWPhFFKhEAYRxREgByAGIAZnjI2ABfbnJYWhBTcTkIBT8IWQ8vHxIkf1Eg0PCRKIcnKkSk5NTyADMqcTAAVxFfVDT0CQ0CgBUdED6Mcd8AbUiLaAbOWEjcFUiAXWa3dFwRLrlTUqS3E_QUsj2Do78CAEECXIBJaCDiWHZt9HvHvP7yLwTKLSTpUDSiHSRFroZRgcQkOYAWRgUJWIy6SxWAHUqIpUZERqYuviAGIiCD4uidSldaCbMgXdA6B65Y4tOTBCBUPIzNz_NKA3yrdbQ8iw-GwGYARg4yw4XFgUoArAqABwKgDsCqlUu1sXYG1OZENSQA3CggA

Steps to Reproduce

  1. Open the link above.
  2. Click the toolbox icon "Box Select".
  3. Drag in the chart to brush an area.
  4. Click the toolbox icon "Switch to Line Chart". Anything else that triggers a full update works too.
  5. Click the toolbox icon "Clear Selections", and then move the mouse out of the icon.

Current Behavior

The highlight of the icon "Clear Selections" does not follow the brushed areas:

Step Brushed areas "Clear Selections"
After step 3 1 Not highlighted
After step 4 1 Highlighted
After step 5 0 Still highlighted

It only goes back to normal after the next full update, for example, after clicking "Switch to Bar Chart".

Expected Behavior

The icon should be highlighted as soon as an area is brushed, and should go back to normal as soon as the areas are cleared.

Environment

- OS: macOS
- Browser: Chrome 153
- Framework: none

Any additional comments?

It can also be reproduced on the current master.

Cause

  • The status of the brush icons is only calculated in render and updateView of the toolbox brush feature (src/component/toolbox/feature/Brush.ts).
  • The action brush is registered with update: 'updateVisual' (src/component/brush/install.ts), and it is the only action that uses it. ToolboxView does not implement updateVisual, so the icons are not updated when the brushed areas are changed.
  • Clicking "Clear Selections" dispatches axisAreaSelect first, which triggers a full update while the areas still exist, and then brush with command: 'clear', which only updates visual. That is why the icon stays highlighted.

Relation to #21684

#21684 fixes that updateView and dispose of ToolboxView do nothing, because the HashMap of features is iterated by zrUtil.each. That fix is needed here, but it does not resolve this issue by itself. I applied it to master and the steps above give the same result.

Possible fix

On top of #21684:

  1. Implement updateVisual in ToolboxView and delegate it to updateView.
  2. Apply the icon status by api.enterEmphasis / api.leaveEmphasis instead of the ones in util/states, so that the states are applied in the next frame even if the status is changed out of a full update.

I have verified this locally and would like to make a pull request for it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions