feat(components): Add getObjectUrl() prop to InputFile#3139
Open
edison-cy-yang wants to merge 3 commits into
Open
feat(components): Add getObjectUrl() prop to InputFile#3139edison-cy-yang wants to merge 3 commits into
edison-cy-yang wants to merge 3 commits into
Conversation
Deploying atlantis with
|
| Latest commit: |
14f3dc5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://96979483.atlantis.pages.dev |
| Branch Preview URL: | https://job-163813-input-file-src-fo.atlantis.pages.dev |
|
Published Pre-release for 14f3dc5 with versions: To install the new version(s) for Web run: To install the new version(s) for Mobile run: |
This file contains hidden or 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
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.
Why Is This Changing?
FileUpload.src()returns adata:URL, which browsers block from top-frame navigation (window.open,<a target="_blank">) for security reasons.<InputFile>.<Gallery>: clicking a non-image thumbnail silently fails withNot allowed to navigate top frame to data URL.src()and substituting a different URL — the fix belongs in the design system.What Is Changing?
FileUpload.getObjectUrl()returns{ url: string; revoke: () => void }— a navigation-safeblob:URL paired with its cleanup function.<Gallery>uses it internally on the non-image thumbnail click path; revoke is scheduled viarequestAnimationFrameafterwindow.open.src()is unchanged. New code should prefergetObjectUrl(); moving away from thesrc()pattern over time without formally deprecating it.InputFileNotes.mdxandGallery.stories.mdx.Consumer Impact
Impact: Low
Action required: None — additive change. Opt into
getObjectUrl()when navigation is needed.Breaking change: No
Existing
src()callers continue to work.getObjectUrlis optional onFileUpload— external consumers constructingFileUpload-shaped objects don't need to provide it.GalleryFilepicksgetObjectUrlfromFileUpload(non-breaking TS change).<Gallery>consumers passingFileUploaddirectly now get working non-image previews — fix, not regression.Validation
InputFile.test.tsxandGallery.test.tsx.InputFileandGallerytests pass unchanged (51 tests, 5 snapshots).Gallery > With InputFiledemonstrates the full flow.Reviewer Notes
{ url, revoke }returned together vs. separate sibling methods onFileUpload. Coupled-return prevents getting the URL without seeing the cleanup handle.getObjectUrl?is optional so external consumers / mocks aren't forced to implement it. Always present on<InputFile>-produced objects.GalleryFilePick: extends the existingPick<FileUpload, ...>instead of redeclaring, so JSDoc and shape stay in sync.requestAnimationFrame(revoke)timing: gives the new tab a frame to start loading before the URL is invalidated. Revoking too early = blank tab; not revoking = leaks until page unload.Changes can be tested via Pre-release.
In Atlantis we use Github's built in pull request reviews.