-
Notifications
You must be signed in to change notification settings - Fork 74
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
plugins: scroll-to functionality #2768
Conversation
jdaviz/components/tray_plugin.vue
Outdated
if (this.scroll_to) { | ||
this.$emit('update:scroll_to', false) | ||
this.$el.scrollIntoView({behavior: "smooth", block: "start"}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mariobuikhuizen - any suggestions to improve this? Right now I handle this by setting a traitlet to True on the python side, and then noticing its true within this callback loop in vue, reverting it to False, and then calling scrollIntoView
. I'm not too worried about the potential slight lag since I think that actually helps show the user where the item came from, but this does result in the element being pulled all the way to the top of the browser page, not just within the parent scrolling element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Screen.Recording.2024-03-26.at.1.58.18.PM.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah block: "nearest"
helps, but then scrolls to the bottom of the plugin when it needs to scroll up instead of down 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can reproduce that behaviour in Firefox, chromium doesn't have this.
This would fix it, although it might be a bit brittle to rely on the .overflow-y-auto
class, which might be susceptible to changes without consideration for its usage here:
const viewport = this.$el.closest(".overflow-y-auto")
const scrollTarget = this.$el.closest(".v-expansion-panel")
viewport.scrollTo({top: scrollTarget.offsetTop, behavior: "smooth"})
// this.$el.scrollIntoView({behavior: "smooth", block: "nearest", inline: "start"});
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2768 +/- ##
==========================================
- Coverage 88.72% 88.72% -0.01%
==========================================
Files 110 110
Lines 16353 16367 +14
==========================================
+ Hits 14509 14521 +12
- Misses 1844 1846 +2 ☔ View full report in Codecov by Sentry. |
c3e2ed7
to
a4359d3
Compare
I'm in favor of default |
The one case I can think of is when opening multiple plugins from a single cell, but agreed that defaulting to True still makes sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support this to defaulting to True, and I can't wait for this to be on main (so many clicks saved!)
Agreed on both counts, this is really nice even if not quite perfect. |
Description
This pull request implements
plugin.open_in_tray(scroll_to=False/True)
functionality as well as using this within the plugin shortcut buttons in the viewer toolbar.Up for discussion:
Screen.Recording.2024-03-27.at.9.08.02.AM.mov
Change log entry
CHANGES.rst
? If you want to avoid merge conflicts,list the proposed change log here for review and add to
CHANGES.rst
before merge. If no, maintainershould add a
no-changelog-entry-needed
label.Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
trivial
label.