Skip to content

Grid navigation edit mode #2328

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

Open
dannify opened this issue Sep 14, 2021 · 5 comments · Fixed by #3258
Open

Grid navigation edit mode #2328

dannify opened this issue Sep 14, 2021 · 5 comments · Fixed by #3258

Comments

@dannify
Copy link
Member

dannify commented Sep 14, 2021

This is to solve for the “Editing and Navigating Inside a Cell” case within grid. A user needs the ability to navigate between elements within a card (cell) without it interfering with the grid navigation. For this, we will need to implement an “edit mode” for the cells. This mode will also be applied to TableView when trying to use components such as textfield that also utilizes arrow key functionality.

Keyboard pattern:

  • Navigate to a cell
  • Press enter
    • If cell doesn’t have any focusable children, do nothing
    • Otherwise, focus the first focusable child
  • You can tab between the elements inside the cell, and it wraps around
  • All other grid navigation keyboard commands are disabled while in edit mode, including arrow keys, typeahead, page up/page down, home/end, etc.
  • Press escape to get out or focus a different cell
  • Provide a way for users to programmatically activate edit mode

See also: https://www.w3.org/TR/wai-aria-practices-1.2/#gridNav_inside

This could be implemented in useGridCell and prevent events from going to useSelectableItem/useSelectableCollection when editing.

API:

Add isEditable prop to Cell and useGridCell

  • When true - arrow key navigation to focusable children is disabled when not in edit mode
  • When false - arrow key navigation to focusable children is enabled (existing behavior).

#3258 has a partial implementation of this edit mode

@LFDanLu LFDanLu mentioned this issue Sep 23, 2021
5 tasks
@LFDanLu LFDanLu moved this to To Groom in RSP Component Milestones Aug 10, 2022
@LFDanLu LFDanLu removed their assignment Aug 10, 2022
@matthewdeutsch matthewdeutsch linked a pull request Aug 10, 2022 that will close this issue
5 tasks
@matthewdeutsch matthewdeutsch assigned LFDanLu and unassigned LFDanLu Aug 10, 2022
@LFDanLu LFDanLu moved this from To Groom to Waiting for Sprint in RSP Component Milestones Aug 10, 2022
@matthewdeutsch matthewdeutsch moved this from 📋 Waiting for Sprint to 🛑 Blocked / Needs More Info in RSP Component Milestones Sep 14, 2022
@ashfaque-pixelotech
Copy link

I am facing the similar issue with react-aria-component. We have built a functionality where user can edit inside the table, inside cells we have inputs and combobox, but there are some issues with input field like "space" key is not working properly getting delayed. clicking on left and right arrow navigate to next cell instead it should move cursor inside the input field. with combobox up and down should navigate between options instead it goes to next row.

if any one have a solution for it that would be a great help.

@rostero1
Copy link

Another thing to consider are filters rendered beneath column names in the table header, as part of the th element. I'm not sure this would fall into the edit mode category. If so, you'd have to have a toggle to hide/show or enable/disable the filters.

@brilliant-ember
Copy link

I can't focus on textfields inside a selectable table row, I am implementing my own selection logic instead of using React-Aria's table selection feature because of that. I don't know if there's another neater workaround

@viktorrenkema
Copy link

viktorrenkema commented Jan 29, 2025

@brilliant-ember I'm encountering the same issues, would you mind sharing what your workaround has been? I'm using Table, TableBody etc from react-aria-components. Tried using the hook-based approach and useTableData from react-stately but the immutability aspect of it has been causing difficulties in our wysiwyg table editor.

@brilliant-ember
Copy link

@brilliant-ember I'm encountering the same issues, would you mind sharing what your workaround has been? I'm using Table, TableBody etc from react-aria-components. Tried using the hook-based approach and useTableData from react-stately but the immutability aspect of it has been causing difficulties in our wysiwyg table editor.

I just made a custom row component that adds a checkbox to the react-aria row, and a context that tracks which rows got selected. Whenever that checkbox gets clicked, it updates a state in the row. Also, it dispatches an event "multiselect" with the id of the row that got selected. Then components who need to listen to that multiselect event got just import that context.

So you just have to use useReducer hook with a context. Here is a link with more information
https://react.dev/learn/scaling-up-with-reducer-and-context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🛑 Blocked / Needs More Info
Development

Successfully merging a pull request may close this issue.

6 participants