-
Notifications
You must be signed in to change notification settings - Fork 426
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: layout shift when uploading images #6930
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
No changes to documentation |
stipsan
force-pushed
the
fix-missing-image-input-buttons-in-react-19
branch
from
June 13, 2024 13:47
07340c2
to
cb9777f
Compare
Component Testing Report Updated Jun 14, 2024 9:04 AM (UTC)
|
stipsan
changed the title
refactor: change
fix: layout shift when uploading images
Jun 13, 2024
ImageInput
from PureComponent
to a memo(React.FC)
stipsan
force-pushed
the
fix-missing-image-input-buttons-in-react-19
branch
from
June 13, 2024 14:55
3471702
to
52ba912
Compare
stipsan
requested review from
pedrobonamin and
bjoerge
and removed request for
a team
June 13, 2024 14:56
stipsan
force-pushed
the
fix-missing-image-input-buttons-in-react-19
branch
from
June 14, 2024 08:52
52ba912
to
8440b9b
Compare
juice49
approved these changes
Jun 14, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Code changes and Studio changes when testing look good to me.
cngonzalez
pushed a commit
that referenced
this pull request
Jun 18, 2024
* refactor: extract `ImageInput->renderPreview` into FC * refactor: extract `ImageInput-> renderHotspotInput ` into FC * refactor: extract `ImageInput-> renderAsset ` into FC * refactor: extract `ImageInput-> renderUploadPlaceholder ` into FC * refactor: extract `ImageInput->renderAssetSource` into FC * refactor: extract `ImageInput->renderAssetMenu` into FC * refactor: use hooks instead of HOC * refactor: extract `ImageInput->renderBrowser` into FC * refactor: replace `BaseImageInput` class component with FC * chore: fix depcheck error * fix: remove layout jumps while uploading images
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This branch started out as an attempt at fixing a React 19 issue where the Image Tool buttons failed to render, and the assumption was that the root cause were that
BaseImageInput
component were still a class component and had bugs in it implementation that linters and typechecks were unable to pick up.After finishing the refactor to a Functional Component the issue were still there, and turned out to be a problem in
@sanity/ui
that's now fixed.Since the refactor to a functional component is still valuable (easier to optimize, allows using hooks instead of hacks like
<ImperativeToast/>
, etc) I kept going and uncovered a bug while testing that the refactor doesn't have regressions:before.image.upload.fix.trimmed.mov
This layout shift issue is recorded on https://test-studio.sanity.build, it's easier to reproduce if slow network conditions are simulated:
This PR includes a fix, here's the new behaviour:
after.image.upload.fix.trimmed.mov
What to review
Does the new code structure make sense? The goal was to reuse existing names as much as possible, and to co-locate things.
Testing
Unsure if existing test suites are enough.
Personally I've tested all the flows I could think of and they're passing:
Notes for release
Reduce layout shift when uploading images that replace existing image assets.