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: Do not overscroll the Teams filter #3951

Merged

Conversation

rumzledz
Copy link
Contributor

@rumzledz rumzledz commented Dec 16, 2024

Description

The left scroll's distance multiplier was somehow causing the team filter to shift way beyond the boundaries so I set it to match the right scroll's distance multiplier, 0.5.

Before After
team-filter-scroll-bug team-filter-scroll-fix

Testing

Note

I don't know any other way for anyone to test this apart from doing this in a Simulator

  1. Open the app on an iOS simulator
  2. Go to the Planex colony dashboard
  3. Click the right arrow for the Teams filter
  4. Click the left arrow for the Teams filter
  5. Verify that the Team filter is not overly scrolled to the point that there is an empty space to its left
  6. To compare, simply checkout to the master branch and redo steps 2 to 4

Resolves #3540

@rumzledz rumzledz self-assigned this Dec 16, 2024
@rumzledz rumzledz marked this pull request as ready for review December 16, 2024 15:21
@rumzledz rumzledz requested a review from a team as a code owner December 16, 2024 15:21
bassgeta
bassgeta previously approved these changes Dec 16, 2024
Copy link
Contributor

@bassgeta bassgeta left a comment

Choose a reason for hiding this comment

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

Hahahah I am sorry for this <3
But thanks for the simple fix, nice one 😎
Tried scrolling, dragging, everything seems to work as intended 👌

arrow-overscroll-2024-12-16_20.34.46.mp4

Nortsova
Nortsova previously approved these changes Dec 16, 2024
Copy link
Contributor

@Nortsova Nortsova left a comment

Choose a reason for hiding this comment

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

Nice catch, @rumzledz 😄

mobile-filter

Copy link
Contributor

@mmioana mmioana left a comment

Choose a reason for hiding this comment

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

Nice start on this issue @rumzledz 🙌

However, I still experience some issues if I select Andromeda for eg. and then try to scroll left

Screen.Recording.2024-12-18.at.22.04.45.mov

I'm leaving my thoughts on how we should maybe refactor the scrollLeft and possibly also the scrollRight functions to properly work

For scrollLeft, we need to ensure the scroll value stays within the available scrollable space. Since -clientWidth * 0.5 could exceed the remaining scrollable space, we should first calculate the remaining space. If the remaining space is smaller than clientWidth * 0.5, we use the remaining space as the scroll offset instead of scrolling by half the width of the container.

Thus this should do the trick

const scrollLeft = () => {
    if (!containerRef.current) {
      return;
    }

    const { clientWidth, scrollLeft: currentScrollLeft } = containerRef.current;
    const boundedScrollLeft = Math.min(clientWidth * 0.5, currentScrollLeft);
    containerRef?.current.scrollBy({
      left: -boundedScrollLeft,
      behavior: 'smooth',
    });
  };

Pretty similar logic also for the scrollRight - which I know is not intended in this PR, but I did notice the right overscroll

const scrollRight = () => {
    if (!containerRef.current) {
      return;
    }

    const {
      clientWidth,
      scrollLeft: currentScrollLeft,
      scrollWidth,
    } = containerRef.current;
    const remainingScroll = scrollWidth - currentScrollLeft - clientWidth;
    const boundedScrollLeft = Math.min(clientWidth * 0.5, remainingScroll);
    containerRef?.current.scrollBy({
      left: boundedScrollLeft,
      behavior: 'smooth',
    });
  };

🙌

@rumzledz rumzledz dismissed stale reviews from Nortsova and bassgeta via 329501f January 7, 2025 12:59
@rumzledz rumzledz force-pushed the fix/3540-maintain-team-filter-position-on-content-scroll branch from dc07e16 to 329501f Compare January 7, 2025 12:59
Copy link
Contributor

@mmioana mmioana left a comment

Choose a reason for hiding this comment

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

Thanks for the changes @rumzledz 🥇 I'll approve given I've already tested them 💯

Copy link
Contributor

@bassgeta bassgeta left a comment

Choose a reason for hiding this comment

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

Another day, another dollar
Another year, another overscroll issue solved 😎

overscroll-fix-2025-01-07_15.35.02.mp4

🚢

Copy link
Contributor

@iamsamgibbs iamsamgibbs left a comment

Choose a reason for hiding this comment

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

Perfect! All working very nicely.

Screen.Recording.2025-01-09.at.14.16.52.mov

@rumzledz rumzledz merged commit 934c4a4 into master Jan 9, 2025
2 checks passed
@rumzledz rumzledz deleted the fix/3540-maintain-team-filter-position-on-content-scroll branch January 9, 2025 19:14
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.

[Dashboard - QA] Team selector widget is shifted and not aligned to the left side
5 participants