Repository navigation
Conversation
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
1 of 7 tasks
…ting usePressLoading hook logic & adjust usePressLoading itself
mikolajpochec
left a comment
Member
There was a problem hiding this comment.
Great work, but I'd like to address a few nitpicks and a possible code cleanup.
40 tasks
…nd-ButtonCompose-instant-spinner Code refactor & simplification
…:software-mansion-labs/expensify-app-fork into @OlGierd03/ButtonCompose-instant-spinner
41 tasks done
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.
Explanation of Change
Adds an opt-in immediate loading state to
ButtonComposed, so a press is acknowledged within a frame instead of after the handler's blocking work. The newshouldShowLoadingImmediatelyOnPressprop wraps the wholeonPress: Button commits a local pressed state, lets React paint the spinner, then runs the handler one macrotask later and hands over to the Onyx-drivenisLoading(where one exists) with no flicker. Turning it on is a one-line change at the call site.The engine is the existing
usePressLoading, generalized for this:isLoadingis now optional (with none passed the pressed state clears once the work settles, instead of waiting for a hand-over that never comes),startWithLoadingawaits async handlers and the focus reset subscribes throughNavigationContextdirectly so a Button rendered outside a navigator is fine.For handlers that validate or branch before doing the work, the prop is the wrong tool (it would spin on a press that does nothing), so those consumers keep calling
usePressLoadingthemselves and pass itsisLoadingin.ButtonContextis split into a state context and an actions context (rulesdir/context-provider-split-values), sinceonPresspublished to the primitives is now the wrapped handler.The same mechanism already shipped for form submits in #92498, and the chart below shows why it's worth spreading: daily INP spans for [data-sentry-label="Form-SubmitButton"] fall from 1K to 1.7K to near zero at the 16 Jul deploy, with the badness score flatlining on the same date (the single badness spike on 12 Aug is an unrelated anomaly):
Fixed Issues
#96058 (see comments: #1, #2)
#96125
Tests
Edit multiplein the selection menu.Edit multiple expensesRHP, open any field (e.g.Description), set a new value and pressSaveon the field page.Edit multiple expensespage, pressSave.Savethe instant it is pressed, before the RHP freezes/dismisses, and that it stays visible until the RHP is dismissed (no frame without the spinner).Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Before:
before_1.mov
After:
after_1.mov