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: Scrolling issues with virtual renderers #3446

Merged
merged 16 commits into from
Oct 29, 2024

Conversation

nicholas-codecov
Copy link
Contributor

@nicholas-codecov nicholas-codecov commented Oct 29, 2024

Description

This PR fixes some issues with the scrolling on the virtual renderers. Basically the issue was that on the diff renderer the last line was being covered up by the scroll bar so you're unable to see it (this is common in virtualized things like this). The solution was to create our own scroll bar that comes after the virtualized content and hook it up to the scrolling behaviour.

I've also tweaked the hit counters slightly, giving them a little extra breathing room.

Notable Changes

  • Create useIsOverflowing hook to determine if we need our custom scroll bar
  • Create useSyncScrollLeft to sync the scroll left value between a base ref, and an array of refs to update when the base ref is scrolled
  • Update styles to remove scroll bars from the textarea and virtualized elements
  • Create a custom scroll bar component
  • Give the hit counters a bit more breathing room when stacked

Screenshots

Left side hit counter:

Screenshot 2024-10-29 at 12 25 21

Scrolling example on diff viewer:

Screen.Recording.2024-10-29.at.10.22.08.mov

Scrolling example on file viewer:

Screen.Recording.2024-10-29.at.10.22.33.mov

@codecov-staging
Copy link

codecov-staging bot commented Oct 29, 2024

Bundle Report

Changes will increase total bundle size by 2.98kB (0.02%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-staging-system-esm 5.55MB 1.34kB (0.02%) ⬆️
gazebo-staging-system 5.5MB 1.64kB (0.03%) ⬆️

Copy link

codecov bot commented Oct 29, 2024

Bundle Report

Changes will increase total bundle size by 2.98kB (0.02%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 5.5MB 1.64kB (0.03%) ⬆️
gazebo-production-system-esm 5.55MB 1.34kB (0.02%) ⬆️

@codecov-staging
Copy link

codecov-staging bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3446   +/-   ##
=======================================
  Coverage   99.15%   99.16%           
=======================================
  Files         808      809    +1     
  Lines       14269    14296   +27     
  Branches     3949     3948    -1     
=======================================
+ Hits        14148    14176   +28     
+ Misses        112      111    -1     
  Partials        9        9           
Files with missing lines Coverage Δ
src/ui/VirtualRenderers/ScrollBar.tsx 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/VirtualDiffRenderer.tsx 98.90% <100.00%> (+0.07%) ⬆️
src/ui/VirtualRenderers/VirtualFileRenderer.tsx 98.21% <100.00%> (+0.21%) ⬆️
src/ui/VirtualRenderers/useIsOverflowing.ts 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/useScrollLeftSync.ts 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/useSyncTotalWidth.ts 100.00% <100.00%> (ø)

... and 19 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.89% <ø> (ø)
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (+<0.01%) ⬆️
UI 99.15% <100.00%> (+0.08%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82b3d3e...ba327ab. Read the comment docs.

Copy link

codecov bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.16%. Comparing base (82b3d3e) to head (ba327ab).
Report is 5 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3446   +/-   ##
=======================================
  Coverage   99.15%   99.16%           
=======================================
  Files         808      809    +1     
  Lines       14269    14296   +27     
  Branches     3942     3948    +6     
=======================================
+ Hits        14148    14176   +28     
+ Misses        112      111    -1     
  Partials        9        9           
Files with missing lines Coverage Δ
src/ui/VirtualRenderers/ScrollBar.tsx 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/VirtualDiffRenderer.tsx 98.90% <100.00%> (+0.07%) ⬆️
src/ui/VirtualRenderers/VirtualFileRenderer.tsx 98.21% <100.00%> (+0.21%) ⬆️
src/ui/VirtualRenderers/useIsOverflowing.ts 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/useScrollLeftSync.ts 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/useSyncTotalWidth.ts 100.00% <100.00%> (ø)

... and 19 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.89% <ø> (ø)
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (+<0.01%) ⬆️
UI 99.15% <100.00%> (+0.08%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82b3d3e...ba327ab. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.16%. Comparing base (82b3d3e) to head (ba327ab).
Report is 5 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3446   +/-   ##
=======================================
  Coverage   99.15%   99.16%           
=======================================
  Files         808      809    +1     
  Lines       14269    14296   +27     
  Branches     3942     3948    +6     
=======================================
+ Hits        14148    14176   +28     
+ Misses        112      111    -1     
  Partials        9        9           
Files with missing lines Coverage Δ
src/ui/VirtualRenderers/ScrollBar.tsx 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/VirtualDiffRenderer.tsx 98.90% <100.00%> (+0.07%) ⬆️
src/ui/VirtualRenderers/VirtualFileRenderer.tsx 98.21% <100.00%> (+0.21%) ⬆️
src/ui/VirtualRenderers/useIsOverflowing.ts 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/useScrollLeftSync.ts 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/useSyncTotalWidth.ts 100.00% <100.00%> (ø)

... and 19 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.89% <ø> (ø)
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (+<0.01%) ⬆️
UI 99.15% <100.00%> (+0.08%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82b3d3e...ba327ab. Read the comment docs.

Copy link

codecov-public-qa bot commented Oct 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.16%. Comparing base (82b3d3e) to head (ba327ab).
Report is 4 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3446   +/-   ##
=======================================
  Coverage   99.15%   99.16%           
=======================================
  Files         808      809    +1     
  Lines       14269    14296   +27     
  Branches     3949     3955    +6     
=======================================
+ Hits        14148    14176   +28     
+ Misses        112      111    -1     
  Partials        9        9           
Files Coverage Δ
src/ui/VirtualRenderers/ScrollBar.tsx 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/VirtualDiffRenderer.tsx 98.90% <100.00%> (+0.07%) ⬆️
src/ui/VirtualRenderers/VirtualFileRenderer.tsx 98.21% <100.00%> (+0.21%) ⬆️
src/ui/VirtualRenderers/useIsOverflowing.ts 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/useScrollLeftSync.ts 100.00% <100.00%> (ø)
src/ui/VirtualRenderers/useSyncTotalWidth.ts 100.00% <100.00%> (ø)

... and 19 files with indirect coverage changes

Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.89% <ø> (ø)
Services 99.45% <ø> (ø)
Shared 99.80% <ø> (+<0.01%) ⬆️
UI 99.15% <100.00%> (+0.08%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82b3d3e...ba327ab. Read the comment docs.

@codecov-releaser
Copy link
Contributor

codecov-releaser commented Oct 29, 2024

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
025aae0 Tue, 29 Oct 2024 15:12:37 GMT Expired Expired
6236866 Tue, 29 Oct 2024 15:45:23 GMT Expired Expired
ba327ab Tue, 29 Oct 2024 16:16:48 GMT Expired Expired
ba327ab Tue, 29 Oct 2024 16:23:08 GMT Cloud Enterprise

@nicholas-codecov nicholas-codecov marked this pull request as ready for review October 29, 2024 15:27
Comment on lines 261 to 265
refsToSync: [codeDisplayOverlayRef, scrollBarRef],
})
useSyncScrollLeft({
scrollingRef: scrollBarRef,
refsToSync: [codeDisplayOverlayRef, textAreaRef],
Copy link
Contributor

Choose a reason for hiding this comment

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

This implies it's not possible to scroll the codeDisplayOverlayRef manually, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the textarea overlays it, so that's what the user interacts with.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool ok! just wanted to sanity check my understanding tyty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They never actually "touch" the virtualized/tokenized code.

const isOverflowing = useIsOverflowing(codeDisplayOverlayRef)

// sync the scroll position of the text area with the code display overlay and scroll bar
useSyncScrollLeft({
Copy link
Contributor

Choose a reason for hiding this comment

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

I found the name of this hook confusing until I read the definition. Didn't know that scrollLeft was an element attribute. IMO useSyncScroll could be more clear, even though it's less specific. Nit though, your call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gonna go with useScrollLeftSync so it reads a bit better, but I personally prefer the slightly more specific naming for clarity.

Copy link
Contributor

@spalmurray-codecov spalmurray-codecov left a comment

Choose a reason for hiding this comment

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

Looks good. Couple comments. Appreciate comments in code, made it easier to understand for sure 🙏

@nicholas-codecov nicholas-codecov added this pull request to the merge queue Oct 29, 2024
Merged via the queue into main with commit adf5b37 Oct 29, 2024
62 checks passed
@nicholas-codecov nicholas-codecov deleted the fix-scrolling-issues-with-virtual-renderers branch October 29, 2024 16:42
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