From db3e0c78c5de56f54bf0307905fad03b3e1c2934 Mon Sep 17 00:00:00 2001 From: Carifio24 Date: Mon, 18 Nov 2024 15:38:13 -0500 Subject: [PATCH] Make sure that the selection layer is always at the top when it's active. --- glue_plotly/viewers/common/viewer.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/glue_plotly/viewers/common/viewer.py b/glue_plotly/viewers/common/viewer.py index 9457df4..b253d91 100644 --- a/glue_plotly/viewers/common/viewer.py +++ b/glue_plotly/viewers/common/viewer.py @@ -121,10 +121,15 @@ def _update_selection_layer_bounds(self): dy = self.state.y_max - self.state.y_min self.selection_layer.update(x0=x0, dx=dx, y0=y0, dy=dy) - def set_selection_active(self, visible): - if visible: + def _bring_selection_layer_to_top(self): + selection_layer = self.selection_layer + self.figure.data = [trace for trace in self.figure.data if trace is not selection_layer] + [selection_layer] + + def set_selection_active(self, active): + if active: self._update_selection_layer_bounds() - # self.selection_layer.update(visible=visible) + self._bring_selection_layer_to_top() + # self.selection_layer.update(visible=active) def set_selection_callback(self, on_selection): self.selection_layer.on_selection(on_selection)