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

feat(scroll): add top offset when automatically scrolling to main-scroll-item #1277

Conversation

CachedaCodes
Copy link
Contributor

@CachedaCodes CachedaCodes commented Sep 11, 2023

EMP-2021

Motivation and context

Depending on the setup's header it was possible that, when automatically scrolling to an element in the main scroll, the element was cut by the header. This feature adds a prop to the main-scroll-item to add an offset to the scrolling.

  • Dependencies. If any, specify:
  • Open issue. If applicable, link:

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that causes existing functionality to not work as expected)
  • Change requires a documentation update

What is the destination branch of this PR?

  • Main
  • Other. Specify:

How has this been tested?

Set the prop and reload a url that has scroll attribute.

@CachedaCodes CachedaCodes requested a review from a team as a code owner September 11, 2023 14:03
Copy link
Contributor

@herrardo herrardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was curious about this and started testing it, but I can't do what I want, it might be some kind of uselessness on my end, but I would like to check it together.

Copy link
Contributor

@lauramargar lauramargar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tried to test it on the archetype and it seems like the element to scroll is always at the bottom. Maybe we can check it together.

@lauramargar
Copy link
Contributor

It works perfectly with the regular results (result component), but I have tried to reload the page with a result of CustomNextQueriesPreview and it doesn't work. I have talked with @CachedaCodes and we found that the problem is an overflow: hidden in the sliding panel of the CustomNextQueriesPreview component.

@@ -99,7 +112,9 @@
oldObserver?.unobserve(this.$el);
newObserver?.observe(this.$el);
if (this.pendingScrollTo === this.item.id) {
this.$el.scrollIntoView();
Vue.nextTick(() => {
this.$el.scrollIntoView();
Copy link
Contributor

@herrardo herrardo Sep 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.$el.scrollIntoView();
this.$el.scrollIntoView({block: 'center'})

After doing some testing, this seems a good option. This option centers always the item in the viewport, so we would have some part of the previous row visible, but the specified item will be always in the view port.

Downside: We would have to modify some test probably.

Screen.Recording.2023-09-13.at.13.03.34.mov

@CachedaCodes CachedaCodes merged commit 42dc680 into main Sep 15, 2023
4 checks passed
@CachedaCodes CachedaCodes deleted the feature/EMP-2021-add-top-offset-when-scrolling-to-scroll-element-from-url branch September 15, 2023 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants