Tap tool selections are cleared with interactive legends

Hello, new member here.

While designing a bokeh dashboard for one of my courses I noticed a very peculiar interaction between the TapTool and interactive legends. Imagine the following scenario: You have a plot consisting of two layers. The first shows many patches (think of it as a heatmap), while the second shows many dots (which are something akin to locations with specific data). You want to be able to select each of these locations with the TapTool. At the same time, if we are not interested in the heatmap data, you should have the ability to hide it using the hide option of plot.legend.click_policy.

Here is a Jupyter notebook example of what I outlined above:

from bokeh.plotting import figure, show, output_notebook
from bokeh.models import ColumnDataSource
output_notebook()

p = figure(plot_width=400, plot_height=400, tools="tap")
circles = ColumnDataSource({"x": [1, 3, 3, 5], "y": [4, 2, 5, 3]})
patches = ColumnDataSource({"xs": [[1,1,2,2],[3,3,4,4]], "ys": [[1,2,2,1],[3,4,4,3]]})
p.circle(source=circles, size=10)
p.patches('xs', 'ys', source=patches, color="red", legend_label="Patches")
p.legend.click_policy="hide"

show(p)

Now onto the problem itself: If I select several points with the TapTool, but then decide to hide the patches by clicking the legend item, the previously made selections are cleared. Here’s a gif of the aforementioned interaction. My question now is: is this intended behaviour? If so, is there a way to prevent this from happening?