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 labels being cut-off in SVG features by rendering feature labels on main thread #3088

Merged
merged 2 commits into from
Jul 13, 2022

Conversation

cmdcolin
Copy link
Collaborator

@cmdcolin cmdcolin commented Jul 12, 2022

Currently, there can be a mismatch between the server and the client when hydrating feature labels since they are floated to the right position on the client side, and this can result in the labels being cut off sometimes

The server tries to float the feature labels in the right place, but a mismatch can still occur because if the user scrolls for example during the time the request is sent to when it is hydrated, it can mismatch.

To help with this, this PR proposes using a useEffect to render the feature only on the main thread (e.g. the useEffect would only be used once hydrated)

There is a caveat for exportSVG which does use the server side to render the features labels in the requested position, there is no main thread "hydration" of the ssr component from the svg export so the useEffect would not be useful in that case

@github-actions github-actions bot added the needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) label Jul 12, 2022
@cmdcolin cmdcolin added bug Something isn't working and removed needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) labels Jul 12, 2022
@cmdcolin cmdcolin changed the title Render feature labels only on main thread for SVG features to fix labels being cut-off Fix labels being cut-off in SVG features by rendering feature labels on main thread Jul 12, 2022
@cmdcolin
Copy link
Collaborator Author

example of feature being cutoff without this PR, see KCND3 label (description is cutoff and it's not floating properly on the left side of the feature)

to reproduce, can whip the scroll around while the track is loading

Screenshot from 2022-07-12 14-23-46

@codecov
Copy link

codecov bot commented Jul 12, 2022

Codecov Report

Merging #3088 (bfd3309) into main (8adb316) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #3088      +/-   ##
==========================================
- Coverage   61.41%   61.39%   -0.03%     
==========================================
  Files         595      595              
  Lines       27216    27221       +5     
  Branches     6563     6566       +3     
==========================================
- Hits        16715    16712       -3     
- Misses      10204    10212       +8     
  Partials      297      297              
Impacted Files Coverage Δ
...src/SvgFeatureRenderer/components/FeatureGlyph.tsx 94.11% <ø> (ø)
...FeatureRenderer/components/SvgFeatureRendering.tsx 72.63% <ø> (ø)
...src/SvgFeatureRenderer/components/FeatureLabel.tsx 80.55% <100.00%> (-3.32%) ⬇️
...svg/src/SvgFeatureRenderer/components/Segments.tsx 85.71% <0.00%> (-7.15%) ⬇️
...gins/svg/src/SvgFeatureRenderer/components/util.ts 91.83% <0.00%> (-4.09%) ⬇️
...rative-view/src/ServerSideRenderedBlockContent.tsx 64.00% <0.00%> (-4.00%) ⬇️
...FeatureRenderer/components/ProcessedTranscript.tsx 87.32% <0.00%> (-1.41%) ⬇️
packages/core/util/layouts/GranularRectLayout.ts 86.86% <0.00%> (-0.43%) ⬇️

Continue to review full report at Codecov.

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

@cmdcolin cmdcolin merged commit 59d9713 into main Jul 13, 2022
@cmdcolin cmdcolin deleted the lazy_feature_labels branch July 13, 2022 15:13
@rbuels
Copy link
Contributor

rbuels commented Jul 19, 2022 via email

@cmdcolin
Copy link
Collaborator Author

this was shipped already :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants