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

fix(select): keep the scrolling position when multiple select true #3065

Merged
merged 2 commits into from
Jul 29, 2024

Conversation

LucyChyzhova
Copy link
Contributor

@LucyChyzhova LucyChyzhova commented Jul 15, 2024

fix: #1268
fix: https://github.com/Lundalogik/crm-feature/issues/2808

Screen.Recording.2024-07-15.at.14.48.14.mov

Review:

  • Commits are atomic
  • Commits have the correct type for the changes made
  • Commits with breaking changes are marked as such

Browsers tested:

(Check any that applies, it's ok to leave boxes unchecked if testing something didn't seem relevant.)

Windows:

  • Chrome
  • Edge
  • Firefox

Linux:

  • Chrome
  • Firefox

macOS:

  • Chrome
  • Firefox
  • Safari
  • Edge

Mobile:

  • Chrome on Android
  • iOS

Copy link

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-3065/

@LucyChyzhova
Copy link
Contributor Author

I tested and unfortunately the new changes brought "the jump" back, so the scrolling position got reset. I will keep my initial commit.

@LucyChyzhova LucyChyzhova force-pushed the limel-select-multiple-items-avoid-top-scrolling branch from 7590138 to abc8288 Compare July 18, 2024 14:44
@john-traas
Copy link
Contributor

The current solution doesn't really fix the issue. In my testing it seemed like at times there were two separate elements being scrolled at the same time.

// Use setTimeout to restore scroll position after a slight delay
setTimeout(() => {
list.scrollTop = scrollPosition;
}, delay);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Using any delay other than 0 introduces a race condition. Either this works with a delay of 0, or we can't rely on this solution as a fix, because it depends on a race condition. (Although, in this case, if it usually works, and only sometimes doesn't, that's a better behaviour for the user than the current behaviour.)

I assume you've already tried this with a delay of 0, but I'll try it myself just in case, and if it doesn't work, I might play around and see if I can get it to work in some other way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Although, in this case, if it usually works, and only sometimes doesn't, that's a better behaviour for the user than the current behaviour.)

I agree!

I assume you've already tried this with a delay of 0, but I'll try it myself just in case, and if it doesn't work, I might play around and see if I can get it to work in some other way.

Thank you, Adrian! 🙏

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please help test my fixup.

It's a pity that John isn't here to help test it, since he's the one who was having problems with the previous implementation… 😕

Copy link
Contributor

@john-traas john-traas Jul 29, 2024

Choose a reason for hiding this comment

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

I am actually reading the thread because I'm curious to see if your fixup will solve it. When I still had the issues, it was when I had selected multiple items, but it wasn't consistent. I tried the requestAnimationFrame but didn't try the setTimeout within the rAF as you did. :D

I'll test it now. It's too hot to be outside so I'm in the living room with a fan on full blast and reading through issues in the cooldown board 😆

@adrianschmidt adrianschmidt force-pushed the limel-select-multiple-items-avoid-top-scrolling branch from abc8288 to e3ac9d8 Compare July 29, 2024 09:51
Copy link
Collaborator

Choose a reason for hiding this comment

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

The current solution doesn't really fix the issue. In my testing it seemed like at times there were two separate elements being scrolled at the same time.

Hm… I'm not seeing anything like that on my machine, and it's working well for me (although with a slight flicker sometimes, but that's not the end of the world).

I wonder if the behaviour you are seeing might be related to the previously mentioned race condition created by setTimeout, or if it's something else… 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm… I'm not seeing anything like that on my machine, and it's working well for me (although with a slight flicker sometimes, but that's not the end of the world).

Same for me 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah! Yeah, there is clearly something weird going on in Edge on Windows:

Screen.Recording.2024-07-29.at.14.23.12.mov

(I have tried in Chrome on macOS, where I'm not having any problems. I haven't tried any other browsers yet.)

Copy link
Contributor

Choose a reason for hiding this comment

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

In Edge on macOS it also has odd behaviours.

Screen.Recording.2024-07-29.at.14.33.48.mov

Copy link
Collaborator

@adrianschmidt adrianschmidt Jul 29, 2024

Choose a reason for hiding this comment

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

I think the problem is that we've added the overflow stuff here: https://github.com/Lundalogik/lime-elements/pull/3065/files#diff-817817636ecff6902e33d23a4566f3ce0c76c4b8c1604695c95b7acc3c40b066R30-R33

I'm pretty sure that the drop down could already overflow and become scrollable, before this PR. And since we haven't changed anything related to that existing functionality, that's still in effect. For some reason, that is getting triggered in Edge. My initial suspicion would be that it happens on systems where scroll bars are taking up space, like they do on Windows. I'm not having any problems in Edge Version 127.0.2651.74 (Official build) (arm64) on my Mac, so I'm going to venture a guess that you have your Mac set to always show scroll bars, @john-traas?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I've solved it. Pushing a fixup in a minute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

testing now!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

YESS! Works everywhere for me! 💥

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup, I've tested it in Chrome, Edge, and Safari on my Mac, and Edge on Windows 11. All work flawlessly as far as I can see 🥳

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll squash and push 👍

@adrianschmidt adrianschmidt force-pushed the limel-select-multiple-items-avoid-top-scrolling branch from 79fe717 to 8a168d6 Compare July 29, 2024 12:09
return;
}

const scrollPosition = list.scrollTop;
const scrollPosition = menuSurface.scrollTop;
Copy link
Contributor Author

@LucyChyzhova LucyChyzhova Jul 29, 2024

Choose a reason for hiding this comment

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

ah!! I should not use list there! but menuSurface
and .mdc-menu-surface and not limel-menu-surface

Copy link
Collaborator

Choose a reason for hiding this comment

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

Look at the whole fixup. That's "the same" variable, I just renamed it, because I changed so that it wasn't holding the list, but the menu-surface.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Here's what the fixup looked like before I squashed it:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, missed the top part.

@adrianschmidt adrianschmidt force-pushed the limel-select-multiple-items-avoid-top-scrolling branch from a7c88a4 to dbacd80 Compare July 29, 2024 14:15
@LucyChyzhova LucyChyzhova merged commit be0782d into main Jul 29, 2024
11 checks passed
@LucyChyzhova LucyChyzhova deleted the limel-select-multiple-items-avoid-top-scrolling branch July 29, 2024 14:21
@lime-opensource
Copy link
Collaborator

🎉 This PR is included in version 37.55.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

limel-select with multiple=true: selecting an option always scrolls the list of options to the top
5 participants