-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 mobile transaction form requires additional click to unfocus amount input #3274
base: master
Are you sure you want to change the base?
Fix mobile transaction form requires additional click to unfocus amount input #3274
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller
Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset No files were changed View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
cc @joel-jeremy would you mind taking a look at this as our mobile expert? :) |
This behavior was intentional and the changes here will break the hook that enforces this behavior (atleast on Chrome based browsers). The point of the hook is to only have one field being active/edited at any given time. If you click on another field while another one is active, it should not activate the clicked field but instead deactivate the current active field. I'm open to ideas on how to handle forms on mobile but this is what I was able to come up with so far. If we are able to remove the need for this hook while having a better UX then I'm all for it. :) |
But what's the point of that behaviour? For me it is annoying because requires doubletap between the fields. I don't think I have seen such thing in any app. |
For context - that was introduced because previously the mobile budget page was all edited inline. Which means you cant just easily click out of the currently edited field e.g. Budgeted to save it without clicking on another field e.g. Spent. Today, it's not much of an issue since the budget page fields have all been migrated to open up modals. With that, I'm okay with removing the hook altogether since the mobile app's design has now migrated away from needing this functionality. |
That makes sense, thank you. I will then go ahead and remove that hook altogether. |
@joel-jeremy removed |
Thanks! Now that the blur logic has changed, I now see a bug where if you create a split transaction, set an amount, click on another field e.g. category, the amount does not get set properly. We may need to start using onChange here instead of onBlur to set the values. |
Either I can't reproduce it from my end, or I don't get what's the issue. Do you have more detailed "how to reproduce"? :) |
@coderabbitai full review |
WalkthroughThe pull request includes significant changes to several components in the desktop client, focusing on simplifying state management related to focus handling in forms. The Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
upcoming-release-notes/3274.md
is excluded by!**/*.md
📒 Files selected for processing (5)
- packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx (4 hunks)
- packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (6 hunks)
- packages/desktop-client/src/components/modals/ReportBudgetMenuModal.tsx (2 hunks)
- packages/desktop-client/src/components/modals/RolloverBudgetMenuModal.tsx (2 hunks)
- packages/desktop-client/src/hooks/useSingleActiveEditForm.tsx (0 hunks)
💤 Files with no reviewable changes (1)
- packages/desktop-client/src/hooks/useSingleActiveEditForm.tsx
🔇 Additional comments (9)
packages/desktop-client/src/components/modals/ReportBudgetMenuModal.tsx (1)
79-79
: Approve change with clarification requestThe addition of
defaultFocused={true}
to theFocusableAmountInput
component aligns well with the PR objectives. It addresses the issue of requiring an additional click to focus on the amount input and simplifies focus management.However, there are a couple of points that need clarification:
The AI summary mentions the removal of
amountFocused
state and associated logic, but these changes are not visible in the provided code. Could you please confirm if these changes were made and if so, provide the updated code?While setting
defaultFocused={true}
solves the immediate issue, are there any potential side effects of always having the amount input focused by default? For example, could this interfere with keyboard navigation or accessibility features?To verify the removal of
amountFocused
state and associated logic, please run the following script:packages/desktop-client/src/components/modals/RolloverBudgetMenuModal.tsx (2)
81-81
: Approve change with suggestions for further verificationThe addition of
defaultFocused={true}
to theFocusableAmountInput
component aligns well with the PR objectives. It simplifies focus management and potentially improves the user experience by reducing the number of clicks required to interact with the form.To ensure the change meets the intended goals:
- Please verify this behavior on various mobile devices to confirm it resolves the double-tap issue mentioned in the PR objectives.
- Consider any potential side effects this change might have on the overall form interaction, especially in light of the previous concerns about maintaining only one active field at a time.
✅ Verification successful
Change verified and approved
The addition of
defaultFocused={true}
to theFocusableAmountInput
component is consistently applied across the codebase, ensuring uniform focus management and enhancing the user experience as intended by the PR objectives.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any other instances of FocusableAmountInput that might need similar changes # Test: Search for other usages of FocusableAmountInput rg --type typescript 'FocusableAmountInput'Length of output: 243
Script:
#!/bin/bash # Description: Search for all instances of FocusableAmountInput in TypeScript and TSX files # Search for 'FocusableAmountInput' in .ts and .tsx files rg 'FocusableAmountInput' --glob '*.ts' --glob '*.tsx'Length of output: 1010
Script:
#!/bin/bash # Description: Inspect FocusableAmountInput usage in ReportBudgetMenuModal.tsx for focus management # Search for props passed to FocusableAmountInput in ReportBudgetMenuModal.tsx rg 'FocusableAmountInput\s*\(' packages/desktop-client/src/components/modals/ReportBudgetMenuModal.tsx --multilineLength of output: 116
Script:
#!/bin/bash # Description: Extract props passed to FocusableAmountInput in ReportBudgetMenuModal.tsx # Search for all instances of FocusableAmountInput in JSX and display the props rg '<FocusableAmountInput\s[^>]*>' packages/desktop-client/src/components/modals/ReportBudgetMenuModal.tsx --multilineLength of output: 656
Line range hint
1-105
: Overall simplification looks good, but warrants careful testingThe removal of explicit focus management using
useState
anduseEffect
hooks (as mentioned in the AI summary) simplifies the component and aligns with the PR objectives. This change, combined with the addition ofdefaultFocused={true}
, should improve the user experience.However, given the extent of the changes and the concerns raised in the PR comments, I recommend:
- Thorough testing of all form interactions, especially for split transactions. The PR comments mention a potential issue with setting amounts in split transactions, which should be carefully verified.
- Monitoring for any regressions related to focus management across different scenarios and device types.
- Verifying that the removal of the
useSingleActiveEditForm
hook (mentioned in PR comments) doesn't introduce unexpected behaviors in other parts of the application.Consider documenting the rationale behind this simplification in the component or in a separate architecture document. This will help future maintainers understand the design decisions and the trade-offs made.
packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx (1)
162-162
:⚠️ Potential issueRenaming 'focused' prop to 'defaultFocused' may impact existing component usage
Changing the prop name from
focused
todefaultFocused
modifies the public API of theFocusableAmountInput
component. This can affect other parts of the codebase that rely on thefocused
prop. Please ensure that all instances whereFocusableAmountInput
is used with thefocused
prop are updated to prevent any unexpected behavior.Run the following script to identify usages of the old
focused
prop:packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (5)
349-349
: Consistent Disabling of Category FieldThe addition of
disabled={isOffBudget || isBudgetTransfer(transaction)}
on line 349 ensures that the category field is disabled when the transaction is off-budget or a budget transfer. This maintains consistency with the intended behavior and prevents unintended category changes.
679-679
: Enhance User Experience by Focusing Amount InputSetting
defaultFocused={true}
on theFocusableAmountInput
component ensures that the amount field is focused when the page loads. This improves the user experience by allowing immediate data entry without additional clicks.
719-719
: Disable Category Field for Off-Budget and Transfer TransactionsAdding
disabled={isOffBudget || isBudgetTransfer(transaction)}
on line 719 aligns the parent transaction's category field behavior with the child transactions. This prevents editing the category when it's not applicable, maintaining consistency across the form.
783-783
: Verify Disabling Account Change on Existing TransactionsThe account field is now disabled for existing transactions (
disabled={!adding}
) on line 783. While this might prevent unintended changes, it also restricts users from correcting mistakes in the account selection.Please confirm that preventing account changes on existing transactions is intentional and doesn't hinder necessary edits. If users need the ability to change accounts, consider enabling this field.
1113-1120
: Modernize Code with React HooksReplacing the
connect
HOC with React hooks (useSelector
,useCategories
,useAccounts
, etc.) simplifies the component and aligns with current best practices. This refactoring enhances readability and maintainability of the code.
packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx
Outdated
Show resolved
Hide resolved
packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx
Show resolved
Hide resolved
packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx
Show resolved
Hide resolved
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx
Outdated
Show resolved
Hide resolved
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.
@minajevs Could you update the branch with master? It looks like there's some merge conflicts.
Fixed the issue. Pushing updates onChange instead of onBlur caused additional weird issues with scrolling. Instead it will now just always push updates onBlur, without a condition. Seems to be working ok. After merging latest master there also appeared a new issue with immediate payee/category/etc. modals, as they received stale update callbacks. Solved it with refs, so should be fine now. @joel-jeremy @MikesGlitch can you please review it again? :) |
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx
Show resolved
Hide resolved
packages/desktop-client/src/components/modals/TrackingBudgetMenuModal.tsx
Show resolved
Hide resolved
/update-vrt |
Closes #3268
So the "bug" happened because
setTimeout
inonBlur
handler messed up event-loop. The current edited field was reset on the next cycle, afteronClick
handler of the next field was fired. RemovingsetTimeout
linearizes event-loop and current edited field is reset beforeonClick
is fired.