Uh oh!
There was an error while loading. Please reload this page.
Enable & disable predefined modebar buttons via layout and template - #5660
Conversation
nicolaskruchten
commented
May 14, 2021
I thought we'd settled on layout.modebar.(add|remove) ? No "buttonsto" |
archmoj
commented
May 14, 2021
Renamed in aeb1626. |
nicolaskruchten
commented
May 14, 2021
Thanks! Is implementing "remove" a lot of additional work? |
archmoj
commented
May 14, 2021
Maybe no. But the need for that is not clear? Is it to hide every possible button? Not these hidden by default ones? |
nicolaskruchten
commented
May 14, 2021
For symmetry and yes, to be able to remove additional buttons like the zoom buttons for example or home/reset-axes |
nicolaskruchten
commented
May 14, 2021
Basically a layout equivalent to config.modebarButtonsToRemove which gets used fairly often in the wild. |
| var buttonsToAdd = context.modeBarButtonsToAdd | ||
| .concat(fullLayout.modebar.add.split('+')); | ||
| var buttonsToRemove = context.modeBarButtonsToRemove | ||
| .concat(fullLayout.modebar.remove.split('+')); |
There was a problem hiding this comment.
Trying to think if there are any cases we need to explicitly deal with precedence of config over layout. That's the way we decided it should work, right?
If config adds a button that layout has asked to remove, it can add it via the full object, but the string versions aren't defined in the add section below.
And if config removes a button that layout has asked to add, since removal happens first it won't be available yet when it's expected to be removed, so it will appear anyway.
So it seems like these concat need to filter out layout items that are in the opposite context entry.
| ].join(' ') | ||
| }, | ||
| add: { | ||
| valType: 'flaglist', |
There was a problem hiding this comment.
Using a flaglist here is convenient for validation, but it's different from the API we use for config, an array. Here we don't need to support the object form, which obviously wouldn't fit in a flaglist, I just wonder if ease of validation is sufficient reason to differ. @nicolaskruchten thoughts?
There was a problem hiding this comment.
I prefer an array, like in config
alexcjohnson
left a comment
There was a problem hiding this comment.
💃 looks good. Great tests!
This PR moves attributes and supply default files into
component/modebar, registermodebarincore.jsand thenresolves#5623 by introducing
modebar.addandmodebar.removeoptions.Also this PR help simplify use of
config.modeBarButtonsToRemoveby accepting short name variations.For example one could use
zoomininstead ofzoomIn2dto disable zoom in buttun.@plotly/plotly_js