Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot brush sometimes "sticky" and doesnt clear as expected #46

Closed
tsostarics opened this issue Dec 29, 2023 · 6 comments
Closed

Plot brush sometimes "sticky" and doesnt clear as expected #46

tsostarics opened this issue Dec 29, 2023 · 6 comments
Labels
bug Something isn't working question Further information is requested

Comments

@tsostarics
Copy link
Owner

I'm not entirely sure how to reproduce this, but sometimes the previous selection will not be cleared when a second selection is made. Very rarely, the previous selection will be used as the active selection instead of the newer selection.

@tsostarics tsostarics added bug Something isn't working question Further information is requested wontfix This will not be worked on labels Dec 29, 2023
tsostarics added a commit that referenced this issue May 12, 2024
@tsostarics
Copy link
Owner Author

tsostarics commented May 13, 2024

This issue is still around and I'm still unable to reproduce it, but I've been told by others that it occasionally happens to them as well. I've added a button to clear the selection, so hopefully that works as a bandaid for the time being. Apparently the plot brush doesn't distinguish between a click event and a click+hold (for brushing), so I can't map session$resetBrush to a click event.

Things that do not seem to reliably reproduce the issue:

  • Rapidly making selections
  • Resizing/moving/maximizing the window when a selection exists
  • Clicking inside a selection
  • Making a selection that completely encapsulates the previous selection
  • Making a selection while pressing F to toggle points
  • Right clicking a selection
  • Moving to a new file when a selection exists
  • Using the regex box to plot multiple files when a selection exists

@tsostarics tsostarics removed the wontfix This will not be worked on label May 13, 2024
@tsostarics
Copy link
Owner Author

See also discussion here, I think it's referencing the same problem: rstudio/shiny#3683

@tsostarics
Copy link
Owner Author

tsostarics commented May 15, 2024

Anecdotally this seems to happen very frequently for MacOS users, and may be related to moving between windows or desktops. Sadly the implemented clear selection button doesn't target the sticky boxes since they're no longer related to input$plot_brush (which I half expected but nice to have confirmation). Given that the boxes appear even when the plot rerenders, one brute force approach might be to use Javascript to straight up delete any div element corresponding to the selection box.

@tsostarics
Copy link
Owner Author

Based on the idea in the above comment, I've applied a band-aid fix such that pressing the clear select button will not only reset the current brush but it will also run a line of javascript to delete the div with the id pulsePlot_brush. When there's a "sticky" box there are 2 divs with the same id, but running session$resetBrush should remove the first/active brush div, then the javascript should target the remaining one. However, you'd need to keep pressing it if there are more on the screen.

This is still difficult to reproduce, but you can hack it into existence by drawing a brush, opening up the HTML in the dev tools, copying the pulsePlot_brush element, then pasting it after making a new box. The pasted box will persist. If you drag a new box, then navigate to another file, then that new box will also start to persist. In other words, once you have one sticky box, you'll start getting a lot more sticky boxes:

image

I'll push a version that uses a loop to delete all the boxes at once in a moment. In JS, document.getElementById("pulsePlot_brush") will return null if no element with the given id exists.

@tsostarics
Copy link
Owner Author

This is now fixed in the sense that there exists a solution to get rid of the boxes, but I do think the underlying issue is related to the plot brush debouncing behavior described in the cited PR from before. So, we have a band-aid of a fix now and until Shiny itself is updated to fix the brush I don't think it's going to be solved.

@dvg-p4
Copy link

dvg-p4 commented Sep 24, 2024

Yeah, the underlying issue is that brushing functionality in shiny is really just duct-taped and hot-glued on, it's a truly impressive bodge. Unfortunately, I'm probably not going to get another month of company time to bring that PR up to date with recent shiny changes, and it's unclear whether the maintainers would review it even if I did, so I wouldn't hold your breath on a fix in Shiny. I'd suggest looking into alternatives like plotly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants