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

plugins: scroll-to functionality #2768

Merged
merged 4 commits into from
Mar 29, 2024
Merged

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Mar 26, 2024

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:

  • should this default to True or False (for the API)?
Screen.Recording.2024-03-27.at.9.08.02.AM.mov

Change log entry

  • Is a change log needed? If yes, is it added to 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, maintainer
    should 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.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone. Bugfix milestone also needs an accompanying backport label.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry added this to the 3.9 milestone Mar 26, 2024
@github-actions github-actions bot added documentation Explanation of code and concepts cubeviz specviz mosviz imviz plugin Label for plugins common to multiple configurations specviz2d labels Mar 26, 2024
Comment on lines 48 to 51
if (this.scroll_to) {
this.$emit('update:scroll_to', false)
this.$el.scrollIntoView({behavior: "smooth", block: "start"});
}
Copy link
Member Author

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.

Copy link
Member Author

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

Copy link
Member Author

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 🤔

Copy link
Collaborator

@mariobuikhuizen mariobuikhuizen Apr 3, 2024

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"});

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 88.72%. Comparing base (f1ba4a6) to head (c3e2ed7).
Report is 6 commits behind head on main.

❗ Current head c3e2ed7 differs from pull request most recent head 481bf30. Consider uploading reports for the commit 481bf30 to get more accurate results

Files Patch % Lines
jdaviz/core/template_mixin.py 60.00% 2 Missing ⚠️
jdaviz/core/tools.py 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@kecnry kecnry marked this pull request as ready for review March 27, 2024 13:09
@bmorris3
Copy link
Contributor

should this default to True or False (for the API)?

I'm in favor of default True for the API. There's ~no point in opening a plugin in the tray without being able to see it.

@kecnry
Copy link
Member Author

kecnry commented Mar 28, 2024

There's ~no point in opening a plugin in the tray without being able to see it.

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.

Copy link
Contributor

@gibsongreen gibsongreen left a 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!)

@rosteen
Copy link
Collaborator

rosteen commented Mar 29, 2024

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.

@kecnry kecnry merged commit d5a049f into spacetelescope:main Mar 29, 2024
18 checks passed
@kecnry kecnry deleted the scroll-to-plugin branch March 29, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cubeviz documentation Explanation of code and concepts imviz mosviz plugin Label for plugins common to multiple configurations Ready for final review specviz specviz2d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants