plotly / plotly/plotly.js

[CHORE]: Update modebar button names to be more accurate/consistent

Open
#7,942 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

chore P3 plotly-internal size: 1 task
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

Description

Update existing modebar button/group names to be more accurate/consistent.

Three related inconsistencies in how modebar buttons are named:

  • resetViewSankey reports a different name than its key. It is registered as modeBarButtons.resetViewSankey but carries name: 'resetSankeyGroup' - the only mismatch among the 37 buttons. Removing it therefore requires modeBarButtonsToRemove: ['resetSankeyGroup'], while config.modeBarButtons groups use 'resetViewSankey'.
  • _cat: 'reset' matches only resetGeo. It reads like a category but leaves resetViews, resetScale2d, resetViewMap, and the sankey reset in place.
  • _cat: 'resetView' matches only resetViewMap, so it misses the sankey reset despite the name suggesting otherwise.

All of these strings are advertised in the layout.modebar.remove enumeration (48 entries), so they are public API.

Why should this change be made?

Users reasonably expect a button's removal string to match its key, and a category alias to cover a family. Today remove: 'reset' and remove: 'resetView' silently no-op on most reset buttons, and the sankey button can only be removed by a name that appears
nowhere else. Compare the aliases that do behave as categories: zoom (2 buttons), pan (2), zoomin / zoomout (3 each), hoverclosest (4).

Scope
  • src/components/modebar/buttons.js - name on resetViewSankey, and the _cat values for reset / resetView.
  • src/components/modebar/constants.js builds foreButtons from name + _cat, so any change regenerates the schema enumeration (npm run schema, committing test/plot-schema.json and src/types/generated/schema.d.ts).
  • src/types/core/layout.d.ts - ModeBarDefaultButtons currently lists both resetViewSankey and resetSankeyGroup
Notes
  • All of these changes are breaking
  • Nothing is wrong with the current code, but it can be confusing
  • _cat casing is inconsistent (hoverCompare, resetCameraDefault, resetView vs hoverclosest, zoomin, autoscale) and should be addressed at the same time (though it's only cosmetic)
  • Every item breaks working code - renaming the sankey name invalidates modeBarButtonsToRemove: ['resetSankeyGroup'], and widening the _cat aliases makes existing remove calls take out more buttons. So this belongs in a major release; v4 is the window if it's wanted at all. Separately, _cat casing is inconsistent (hoverCompare, resetCameraDefault, resetView vs hoverclosest, zoomin, autoscale) - cosmetic only, since matching lowercases both sides.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/components/modebar/buttons.js and src/components/modebar/constants.js to trace how button names and _cat values become removal aliases. Update the listed modebar names and categories, then run npm run schema and verify test/plot-schema.json, src/types/generated/schema.d.ts, and src/types/core/layout.d.ts reflect the public API changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
data-visualization
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.