[BUG] TypeError after replacing tools on a toolbar
See original GitHub issueMy plot should have different sets of tools depending on what is displayed.
setting plot.toolbar
doesn’t help since the toolbar model change not not handled correctly.
Executing something like plot.toolbar.tools = new_tools_list
seems to work but results in this exception in JS console:
bokeh.js:30582 Uncaught TypeError: Cannot read property 'el' of undefined
at el (bokeh.js:30582)
at Array.map (<anonymous>)
at ToolbarBaseView.render (bokeh.js:30586)
at ToolbarPanelView.render (bokeh.js:11764)
at PlotView._paint_levels (bokeh.js:22064)
at PlotView.paint (bokeh.js:22044)
at PlotView.repaint (bokeh.js:21983)
at PlotView.<anonymous> (bokeh.js:21892)
at Signal0.Signal.emit (bokeh.js:4167)
at Signal0.emit (bokeh.js:4180)
Both Toolbar
and ToolbarBaseView
attach a signal on the tools
property change. However, the Toolbar.gestures
property change does not remove the old references:
// Toolbar._init_tools()
if (!some(this.gestures[et].tools, (t) => t.id == tool.id))
this.gestures[et].tools = this.gestures[et].tools.concat([tool])
Because of this, only the addition of tools works without errors. And while gestures
is a property in BokehJS, it is not in the Python counterpart.
Similar code can be seen in ProxyToolbar
but it doesn’t handle the changes to the list of tools at all, so I guess it was never on the plate.
While it’s not reflected in the error above, other attributes have the same issue of not being pruned on tools change: inspectors
, help
, actions
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
It will be a bit more intrusive since a proper fix would also change
ProxyToolbar
. I’ll come up with a PR soon.Seems to work fine now.
@bryevdv Oh no, sorry for that rant. I completely get the virtues TS provides for projects similar to Bokeh (big code base, multiple contributors from different backgrounds). It’s just that I’m mostly used to writing code for other kinds of projects, with no such needs.