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: handle shift tab tab-index focus #6554

Merged
merged 7 commits into from
Feb 8, 2025

Conversation

VipinDevelops
Copy link
Contributor

@VipinDevelops VipinDevelops commented Feb 5, 2025

Handled Tab-Shift to move to next element in the creation modal

Screen.Recording.2025-02-08.at.1.04.32.AM.mov

This pull request focuses on improving the handling of tabIndex across various dropdown components and input fields in the codebase. The main changes include adding or removing tabIndex attributes to ensure proper keyboard navigation and accessibility.

Handling of tabIndex in dropdown components:

  • Added tabIndex attribute to button elements in CycleDropdown, MemberDropdown, ModuleDropdown, PriorityDropdown, and StateDropdown components to improve accessibility. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

  • Removed tabIndex attribute from ComboDropDown elements in the same components to avoid redundant or conflicting tab indices. [1] [2] [3] [4] [5]

Handling of tabIndex in input fields and forms:

  • Added tabIndex to the container div in IssueTitleInput and adjusted the tabIndex of the input field for better focus management. [1] [2]

  • Modified IssueFormRoot to include tabIndex on div elements wrapping buttons to enhance focus control. [1] [2]

Miscellaneous changes:

  • Removed unnecessary Combobox.Button wrapper in IssueLabelSelect to simplify the structure and ensure proper tabIndex handling. [1] [2]

These changes collectively aim to improve the accessibility and user experience of the application by ensuring consistent and logical keyboard navigation.

Summary by CodeRabbit

  • New Features
    • Enhanced keyboard navigation across the application, ensuring a more intuitive and consistent experience when using keyboard shortcuts in list editing, dropdown menus, and modal dialogs.
    • Improved focus management for interactive elements such as issue inputs and labels, allowing easier and more predictable navigation.

  • Refactor
    • Streamlined component interactions to provide a uniform and accessible user interface without altering core functionalities.

Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

The changes enhance keyboard navigation across several dropdown components by adding the tabIndex property to button elements. This adjustment allows for better control over focus order and accessibility. Additionally, a condition was added in the ListKeymap extension's addKeyboardShortcuts method for the "Shift-Tab" handler, ensuring consistent behavior with the "Tab" shortcut. The overall structure and functionality of the components remain unchanged, with no alterations to exported or public entities.

Changes

File Change Summary
packages/editor/.../custom-list-keymap/list-keymap.ts Added a condition in the addKeyboardShortcuts method for the "Shift-Tab" shortcut to check if tabIndex is defined, returning false to prevent default behavior, mirroring the "Tab" handler logic.
web/core/components/dropdowns/cycle/index.tsx Added tabIndex property to button elements in the CycleDropdown component and removed it from the ComboDropDown component.
web/core/components/dropdowns/member/index.tsx Added tabIndex property to button elements in the MemberDropdown component and removed it from the ComboDropDown component.
web/core/components/dropdowns/module/index.tsx Added tabIndex property to button elements in the ModuleDropdown component and removed it from the ComboDropDown component.
web/core/components/dropdowns/priority.tsx Added tabIndex property to button elements in the PriorityDropdown component and removed it from the ComboDropDown component.
web/core/components/dropdowns/state.tsx Added tabIndex property to button elements in the StateDropdown component and removed it from the ComboDropDown component.
web/core/components/issues/select/label.tsx Removed the Combobox.Button wrapper around the button in IssueLabelSelect, simplifying the structure while maintaining functionality.
web/core/components/issues/issue-modal/components/title-input.tsx Replaced fragment with a <div> in IssueTitleInput, adding a tabIndex attribute and removing it from the Input component.
web/core/components/issues/issue-modal/form.tsx Added tabIndex attributes to <div> elements wrapping buttons for improved accessibility and removed original tabIndex from the button for creating more issues.

Suggested labels

🐛bug, 🌟improvement, 🌐frontend

Suggested reviewers

  • SatishGandham
  • sriramveeraghanta
  • rahulramesha

Poem

I'm a merry rabbit, hopping through the code,
With every shortcut tweak, a lighter load.
"Shift-Tab" now stops when tabIndex glows,
My logic hops in sync, as the workflow flows.
Celebrate with a twitch of ear and a joyful nod!


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@CLAassistant
Copy link

CLAassistant commented Feb 5, 2025

CLA assistant check
All committers have signed the CLA.

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

🧹 Nitpick comments (1)
packages/editor/src/core/extensions/custom-list-keymap/list-keymap.ts (1)

54-56: LGTM! Consider adding a clarifying comment.

The implementation correctly mirrors the Tab handler's behavior for tabIndex, ensuring consistent keyboard navigation.

Consider adding a comment similar to line 42 for clarity:

+          // if tabIndex is set, we don't want to handle Shift-Tab key
           if (tabIndex !== undefined && tabIndex !== null) {
             return false;
           }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89d1926 and 33ae5c6.

📒 Files selected for processing (1)
  • packages/editor/src/core/extensions/custom-list-keymap/list-keymap.ts (1 hunks)

@VipinDevelops VipinDevelops marked this pull request as draft February 5, 2025 12:42
@VipinDevelops VipinDevelops marked this pull request as ready for review February 7, 2025 04:59
@Palanikannan1437 Palanikannan1437 changed the title handle shift tab tab-index focus fix: handle shift tab tab-index focus Feb 7, 2025
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

🧹 Nitpick comments (1)
web/core/components/dropdowns/state.tsx (1)

144-144: Reorder attributes for consistency.

While the keyboard navigation implementation is correct, consider reordering the attributes in the second button to match the first button's pattern for better code consistency.

-          tabIndex={tabIndex}
-          ref={setReferenceElement}
+          ref={setReferenceElement}
+          tabIndex={tabIndex}

Also applies to: 150-150

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 355a8df and 5c901a2.

📒 Files selected for processing (5)
  • web/core/components/dropdowns/cycle/index.tsx (2 hunks)
  • web/core/components/dropdowns/member/index.tsx (2 hunks)
  • web/core/components/dropdowns/module/index.tsx (2 hunks)
  • web/core/components/dropdowns/priority.tsx (5 hunks)
  • web/core/components/dropdowns/state.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • web/core/components/dropdowns/priority.tsx
🔇 Additional comments (3)
web/core/components/dropdowns/cycle/index.tsx (1)

90-90: LGTM! Keyboard navigation improvements.

The tabIndex prop is correctly added to both button variants, ensuring consistent keyboard navigation behavior.

Also applies to: 108-108

web/core/components/dropdowns/member/index.tsx (1)

116-116: LGTM! Consistent keyboard navigation implementation.

The tabIndex prop is correctly implemented, matching the pattern used in other dropdown components.

Also applies to: 134-134

web/core/components/dropdowns/module/index.tsx (1)

238-238: LGTM! Comprehensive keyboard navigation support.

The tabIndex prop is correctly implemented, supporting keyboard navigation for both simple and complex button content scenarios.

Also applies to: 256-256

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

🧹 Nitpick comments (1)
web/core/components/issues/issue-modal/components/title-input.tsx (1)

66-66: Remove commented out code.

Instead of keeping the commented tabIndex prop, it should be removed entirely since it's no longer needed.

-            // tabIndex={getIndex("name")}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60fff8e and 614faa4.

📒 Files selected for processing (1)
  • web/core/components/issues/issue-modal/components/title-input.tsx (2 hunks)
🔇 Additional comments (1)
web/core/components/issues/issue-modal/components/title-input.tsx (1)

40-40: LGTM! Moving tabIndex to the container div improves keyboard navigation.

The change aligns with accessibility best practices by controlling focus at the container level.

Please verify that:

  1. Keyboard focus is visually apparent when tabbing to this component
  2. The focus order follows a logical sequence within the form

Also applies to: 72-72

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

🧹 Nitpick comments (2)
web/core/components/issues/issue-modal/form.tsx (2)

503-521: Consider using semantic HTML for better accessibility.

While adding tabIndex improves keyboard navigation, wrapping a single button in a div with tabIndex is redundant as buttons are naturally focusable elements. This could lead to unexpected tab order behavior.

Consider removing the wrapper div and moving the tabIndex directly to the button:

-<div tabIndex={getIndex("discard_button")}>
-  <Button
-    variant="neutral-primary"
-    size="sm"
+<Button
+  variant="neutral-primary"
+  size="sm"
+  tabIndex={getIndex("discard_button")}

522-533: Consider using semantic HTML for better accessibility.

Similar to the discard button, wrapping a single button in a div with tabIndex is redundant and could lead to unexpected tab order behavior.

Consider removing the wrapper div and moving the tabIndex directly to the button:

-<div tabIndex={isDraft ? getIndex("submit_button") : getIndex("draft_button")}>
-  <Button
-    variant={moveToIssue ? "neutral-primary" : "primary"}
-    type="submit"
-    size="sm"
+<Button
+  variant={moveToIssue ? "neutral-primary" : "primary"}
+  type="submit"
+  size="sm"
+  tabIndex={isDraft ? getIndex("submit_button") : getIndex("draft_button")}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 614faa4 and a7745af.

📒 Files selected for processing (2)
  • web/core/components/issues/issue-modal/components/title-input.tsx (2 hunks)
  • web/core/components/issues/issue-modal/form.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/core/components/issues/issue-modal/components/title-input.tsx
🔇 Additional comments (1)
web/core/components/issues/issue-modal/form.tsx (1)

488-488: LGTM! Improved keyboard navigation with tabIndex.

The addition of tabIndex to the outer div enhances keyboard accessibility by making the create more toggle and action buttons focusable.

@sriramveeraghanta sriramveeraghanta merged commit 14083ea into makeplane:preview Feb 8, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants