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 bugs in payee table #3768

Merged
merged 1 commit into from
Nov 2, 2024
Merged

Fix bugs in payee table #3768

merged 1 commit into from
Nov 2, 2024

Conversation

jfdoming
Copy link
Member

@jfdoming jfdoming commented Nov 2, 2024

Two bugs:

  1. [Bug]: Payees can no longer be renamed from payee page #3767
  2. In edge, you can select transfer payees even though the checkbox is invisible.

Ideally we'd have tests for these features. Not feeling super well right now so if someone wants to take a stab at it in the future, I'll make an issue.

@actual-github-bot actual-github-bot bot changed the title Fix bugs in payee table [WIP] Fix bugs in payee table Nov 2, 2024
Copy link

netlify bot commented Nov 2, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 25e25b8
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/672684dcf3f9b00008c54363
😎 Deploy Preview https://deploy-preview-3768.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jfdoming jfdoming changed the title [WIP] Fix bugs in payee table Fix bugs in payee table Nov 2, 2024
Copy link
Contributor

github-actions bot commented Nov 2, 2024

Bundle Stats — desktop-client

Hey 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

Files count Total bundle size % Changed
9 5.32 MB → 5.32 MB (+276 B) +0.00%
Changeset
File Δ Size
src/components/payees/PayeeTable.tsx 📈 +199 B (+15.71%) 1.24 kB → 1.43 kB
src/components/payees/PayeeTableRow.tsx 📈 +77 B (+1.90%) 3.97 kB → 4.04 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 3.33 MB → 3.33 MB (+276 B) +0.01%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/usePreviewTransactions.js 1.64 kB 0%
static/js/AppliedFilters.js 21.3 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/narrow.js 82.57 kB 0%
static/js/wide.js 232.16 kB 0%
static/js/ReportRouter.js 1.5 MB 0%

Copy link
Contributor

github-actions bot commented Nov 2, 2024

Bundle Stats — loot-core

Hey 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

Files count Total bundle size % Changed
1 1.27 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.27 MB 0%

Copy link
Member

@youngcw youngcw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

Copy link
Contributor

coderabbitai bot commented Nov 2, 2024

Walkthrough

The changes introduced in this pull request involve modifications to the PayeeTable and PayeeTableRow components within the desktop client application. In PayeeTable.tsx, a new import statement for the useTableNavigator hook has been added, which facilitates the creation of a tableNavigator variable. This variable is configured to adjust navigation options based on the transfer_acct property of each payee. The tableNavigator is then passed as a prop to the Table component, enhancing its navigation capabilities. In PayeeTableRow.tsx, a conditional check has been added to the onSelect handler of the SelectCell component, preventing selection actions when the payee.transfer_acct property is not null. Additionally, the CustomCell component's render function has been updated to explicitly return undefined when payee.favorite is false. These changes refine the selection logic and clarify the rendering behavior without altering the overall structure of the components.

Possibly related PRs

Suggested labels

sparkles: Merged

Suggested reviewers

  • youngcw

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (3)
packages/desktop-client/src/components/payees/PayeeTable.tsx (1)

58-58: LGTM! Clean integration of navigation controls.

The navigator prop correctly connects the table navigation configuration to the Table component. This approach provides a maintainable solution by centralizing navigation control logic.

Consider documenting this navigation control pattern in your component guidelines, as it provides a reusable solution for similar field accessibility requirements in other tables.

packages/desktop-client/src/components/payees/PayeeTableRow.tsx (2)

Line range hint 151-156: Simplify the conditional rendering logic.

The explicit return for the else case is redundant since undefined is the default return value.

Consider simplifying the code:

          {() => {
            if (payee.favorite) {
              return <SvgBookmark />;
-            } else {
-              return;
            }
          }}

Line range hint 53-54: Consider improving type safety for the onEdit callback.

The field parameter in the onEdit callback could be made more type-safe by using a union type of valid field names instead of string.

Consider updating the type:

-  onEdit: (id: PayeeEntity['id'], field: string) => void;
+  onEdit: (id: PayeeEntity['id'], field: 'name' | 'rule-count' | 'select') => void;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dc42504 and 25e25b8.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/3768.md is excluded by !**/*.md
📒 Files selected for processing (2)
  • packages/desktop-client/src/components/payees/PayeeTable.tsx (2 hunks)
  • packages/desktop-client/src/components/payees/PayeeTableRow.tsx (1 hunks)
🧰 Additional context used
📓 Learnings (1)
packages/desktop-client/src/components/payees/PayeeTableRow.tsx (2)
Learnt from: UnderKoen
PR: actualbudget/actual#3381
File: packages/desktop-client/src/components/payees/PayeeTableRow.tsx:158-159
Timestamp: 2024-09-24T20:31:09.185Z
Learning: When checking with `null`, prefer using `==` instead of `===` to match both `null` and `undefined`, since TypeScript checking is not as strict in this project.
Learnt from: UnderKoen
PR: actualbudget/actual#3381
File: packages/desktop-client/src/components/payees/PayeeTableRow.tsx:158-159
Timestamp: 2024-10-08T15:46:15.739Z
Learning: When checking with `null`, prefer using `==` instead of `===` to match both `null` and `undefined`, since TypeScript checking is not as strict in this project.
🔇 Additional comments (3)
packages/desktop-client/src/components/payees/PayeeTable.tsx (2)

49-53: LGTM! Navigation control effectively prevents transfer payee selection.

The implementation correctly restricts navigation options for transfer payees by only allowing access to 'rule-count', while non-transfer payees can access 'select', 'name', and 'rule-count'. This addresses the Edge browser issue by controlling field accessibility at the navigation level.

Let's verify the completeness of this fix:

#!/bin/bash
# Description: Check for any other places in the codebase where transfer payee selection might be handled
# to ensure consistent behavior across the application.

# Search for transfer_acct related conditions
rg -A 3 "transfer_acct" 

# Search for payee selection related code
ast-grep --pattern 'onSelect($$$)'

49-58: Verify accessibility implications of navigation restrictions.

While the implementation effectively prevents transfer payee selection, we should ensure that screen readers and keyboard navigation provide appropriate feedback when attempting to access restricted fields.

Let's check for accessibility-related code:

✅ Verification successful

Based on the gathered information, I can now provide a final response:

Navigation restrictions are properly handled for keyboard accessibility

The implementation correctly handles keyboard navigation through the useTableNavigator hook, which respects the field restrictions for transfer payees. The Table component includes proper keyboard event handling that:

  • Manages focus navigation between cells
  • Handles enter/tab keys for field navigation
  • Prevents navigation to restricted fields through keyboard events

The navigation restrictions are consistently applied across both mouse and keyboard interactions, ensuring a coherent experience for all users.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Look for accessibility attributes and aria labels
# that might need updating with the new navigation restrictions

# Search for aria-related attributes
rg -g '*.tsx' -g '*.jsx' "aria-"

# Search for accessibility-related tests
fd -e test.tsx -e test.jsx -e spec.tsx -e spec.jsx --exec rg -l "accessibility|aria|screen.reader|keyboard"

Length of output: 31112


Script:

#!/bin/bash
# Look for keyboard navigation and accessibility related code in the Table component
# and its usage in PayeeTable

# Search for keyboard navigation in Table component
ast-grep --pattern 'onKeyDown($$$)' 

# Search for aria attributes and roles in Table component
rg -g '*.tsx' -g '*.jsx' -A 3 'aria-|role=' packages/desktop-client/src/components/table.tsx

# Look for keyboard navigation tests
rg -g '*.test.*' "keyboard|keydown|keypress|keyup" packages/desktop-client/src/components/

Length of output: 794


Script:

#!/bin/bash
# Look for the Table component implementation and its navigation logic

# Search for useTableNavigator hook implementation
ast-grep --pattern 'useTableNavigator($$$)'

# Search for Table component's keyboard handling
rg -g '*.tsx' -g '*.jsx' -A 5 'onKeyDown|handleKeyDown' packages/desktop-client/src/components/table.tsx

# Look for any accessibility-related props or state in PayeeTable
rg -g '*.tsx' -g '*.jsx' -A 5 'aria-|role=|tabIndex' packages/desktop-client/src/components/payees/PayeeTable.tsx

Length of output: 2594

packages/desktop-client/src/components/payees/PayeeTableRow.tsx (1)

136-138: LGTM! This fixes the Edge browser selection issue.

The guard clause effectively prevents selection of transfer payees, addressing the reported Edge browser issue where users could select transfer payees despite invisible checkboxes.

Let's verify there are no other places where transfer payees can be selected:

✅ Verification successful

Based on the search results, I can now verify the review comment. The codebase shows that:

  1. transfer_acct is a field in the payee model that links to an account for transfer payees
  2. The guard clause in PayeeTableRow.tsx correctly prevents selection of transfer payees (when payee.transfer_acct != null)
  3. This is consistent across the codebase - transfer payees are treated specially and are generally not selectable/editable
  4. The UI also reflects this by showing transfer payees differently (with subdued colors and read-only fields)

The guard clause is correctly implemented and aligns with the codebase's handling of transfer payees.

The review comment was correct in approving this change as it properly prevents selection of transfer payees in the Edge browser, consistent with how transfer payees are handled throughout the application.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other potential selection handlers that might need similar guards
ast-grep --pattern 'onSelect={$_}'

Length of output: 36


Script:

#!/bin/bash
# Search for files containing "onSelect" using ripgrep for better coverage
rg "onSelect" --type typescript --type tsx -C 2

# Also search for potential selection handlers with transfer payees
rg "transfer_acct" --type typescript --type tsx -C 2

Length of output: 170


Script:

#!/bin/bash
# Search for files containing "onSelect" without type filtering
rg "onSelect" -C 2

# Also search for potential selection handlers with transfer payees
rg "transfer_acct" -C 2

Length of output: 123458

@jfdoming jfdoming merged commit 6666014 into actualbudget:master Nov 2, 2024
20 checks passed
@jfdoming jfdoming linked an issue Nov 2, 2024 that may be closed by this pull request
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Payees can no longer be renamed from payee page
2 participants