-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: Add support for grid edit mode w/ nested interactive widgets #7277
base: main
Are you sure you want to change the base?
Conversation
useGridList()
useGridList()
useGridList()
This doesn't touch |
packages/@react-aria/gridlist/src/useGridListSelectionCheckbox.ts
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.
As @devongovett suggested, i implemented this for grid cells and added support for edit mode into RAC table.
Test suite is passing, but no new tests added just for now - i added a couple examples to showcase behavior.
Sorry for the large diff - most of it is boilerplate from the new package though 😓
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.
Partial review, will see about wrapping it up soon. Looks promising so far!
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.
Will see about getting this into our upcoming test session on Monday as well
Pushed my last updates, completing what I had in mind for this PR 👍 As mentioned briefly, biggest change from the last review is the introduction of a Another key insight was that, after the edit mode changes, we could remove Lastly i extended support for the disabled state to rows and columns and adjusted the I'm looking forward to your test session feedback to finalize and get started on tests for this beast 😅 ! |
@nwidynski Thanks for all the work you've done here! The team took a closer look today and are a bit concerned about the extent of the changes made. The overall behavior seems promising but we would like to perhaps pare it down into smaller pieces so it is easier to incrementally update the behavior/understand the full ramifications of the impact of these changes. With that in mind, we took some time to implement what we thought was the base amount of changes outlined in #7215 (comment) to support textfields in GridList, you can see those in (WIP) Update GridList so it supports textfields with this simple story. At the moment, that implementation doesn't have "memory" of the last focused element in the GridList and instead opts to focus the last child element of your last focused cell when shift tabbing back into the collection. Any thoughts? Some of the issues you noted in #7215 (comment) still apply but we are debating if saving the "memory" of the last focused element should still apply for non |
@LFDanLu That's unfortunate, but I understand. I originally set out to complete the full spec outlined in #2328, but increasingly became aware of how much change this required while implementing 😬. As to your draft in #7360 , I figure this is addressing the proposed solution in #7125 (comment)? If so, this does not really capture the scope of our original issue #7121, where we proposed preventing all navigation when in As for my thoughts, I feel like the proposed solution in #7125 (comment) is heading down a direction where we shift responsibility for nested interactive widgets down to children or possibly even the consumer to figure out himself, which I wouldn't agree with. In the current state I do not see much of a point in #7360, especially when type select remains active. In regards to the "memory", I think maintaining a stable tab sequence forwards and backwards should be the case for both With current knowledge, I would also advise to follow the notion in #7125 (comment) to leave Regardless, I would definitely still advocate for trying to bring full edit mode capabilities to RAC, because I know a ton of people are awaiting this, just as we are. I think it's the libraries responsibility to handle such a common use-case and I definitely think it's possible to offer full edit mode support out of the box with the current architecture. I can only offer to get this done as digestable as possible through chunking this PR into the following:
My intention is only to get this shipped as quickly as possible, so I'm willing to jump through a couple hoops to get there. I'm afraid this will take months if someone from the community doesn't pick this up, since you guys are understandably busy on S2. Let me know how you guys would like to proceed with this 👍 |
@nwidynski Gotcha, thank you for the detailed response! As you mentioned, the team was moving towards having the children of the cell be responsible for stopping propagation but I can revisit this assumption to them in our meeting tomorrow and see if we may want to pivot there. As for "memory", we have prior precedence doing such tracking in useToolbar, but there have been differing opinions as to what the behavior should be when tabbing back into the collection for specific cases like "blur happened due to change in browser window/mouse click/iframe" which I'll see about getting a consensus from the team about what behavior we want to go with. As for edit mode as a whole, historically when we tried to implement it ourselves I recall that @devongovett still had concerns as to how it should work on mobile touch devices, where perhaps it wouldn't be clear enough to the end user when/how edit mode would be triggered and whether or not there would be confusion around that. I don't quite remember all the details but hopefully I'll be able to comeback with a more detailed answer after tomorrow's meeting. Again, thank you so much for all the work done here, it is greatly appreciated! It quite evident that you've done a lot of good work providing a solution that also matches the ARIA spec, it is just that we need to be extra careful since these are quite hefty changes and as a library we need to make sure that we are ready to accept and maintain this behavior for the foreseeable future. |
Could you explain why you want that? Obviously there are issues with using the arrow keys on certain components such as inputs conflicting with grid navigation, which Daniel's PR has solved, but I don't see any particular issue with still allowing arrow key navigation when focused on an element that does not use the arrow keys. It seems nice to me that this approach allows us to support arbitrary elements such as inputs inside grid cells without needing edit mode at all, while not impacting the behavior of any existing applications.
This is already the case in many ways throughout the library. For example, if you have a button inside a table row, pressing Enter while focused on the button triggers the press event only on that button and does not trigger row selection. That is because the button stops event propagation so the enter key event never reaches the row. The overall principle here is that once the deepest element in the DOM tree handles an event, it should stop propagation to prevent parent elements from also handling it. Without this, we would lose the ability to compose arbitrary components together – the parent would need to know about all of the possible children in order to decide whether to handle an event or not. You can see an example of that in Daniel's PR which does this for native input elements (as a nicety), but we couldn't possibly know all of the other arbitrary components that might handle arrow key navigation without leaving some responsibility to them to stop propagation. |
btw, we definitely want to support a full edit mode in the future in addition to what Daniel proposed, we're just looking to break up the work a bit and hopefully solve some immediate issues that might not require it first. As Daniel mentioned, many of the interactions for edit mode (especially on touch devices) have not yet been defined. |
Thanks for getting back on this so quickly 👍 TLDR;
The flag is called The only difference in our viewpoint is that you guys are trying to shift the decision of AnswerAs you mentioned, it's practically impossible for parent elements to predict what content they will render and shifting actions to children is a common pattern in react-aria. What I meant however, was that there is no slot react-aria could use to carry default behavior to unknown, possibly custom, children. This means we shift all of the prevention responsibility down to the actual user land (not RAC, but actual users) to implement, which obviously isn't working out. Users are attempting, and I think should be able to, render any arbitrary content inside a Leaving user land only an
As a result, I'm advocating here to disable all grid navigation interactions when in |
@devongovett Maybe I should further clarify, after sleeping on this a night.
This is just not true at the moment, since event propagation isn't stopped by the button, but by Unfortunately though, pretty much all components leak keyboard events upwards (demo) when not at one point an This effectively sets up the exact scenario you are wanting to prevent, where a parent now needs to know about all possible children to spread an Am I missing something here entirely? Surely we could stop event propagation even without handlers, but that I feel like would be a much more breaking change 👍 |
It is for tabbing within cells, not between them. You still use arrow keys to do that. There are a few different modes as well, for example in some components the cell itself is never actually focused - focus moves immediately to the first focusable child. If we disabled arrow key navigation in that case, the user would be stuck inside the cell.
I'd say this is more of a bug in TagGroup and/or useSelectableCollection. Ideally those would stop propagation after handling the event. I think we just have not yet encountered nested collection components so this never came up before. We can certainly fix that. I guess what we're discussing here is defaults: in what we proposed, the user can navigate between cells by default and if the developer wants to prevent that they can stopPropagation. In what you proposed, there's less work for the developer because they don't need to stop propagation to prevent arrow key navigation, but it's also not possible to enable the user to navigate between cells with the arrow keys at all (which might make the UI easier to use).
I guess this still shifts the burden to the developer to know that this is something they need to use, the same way as stopPropagation would. I think we should consider the ideal user behavior here first, e.g. whether arrow key navigation on elements such as buttons within cells should move focus between cells. Needing to shift tab back out in order to do that might not be expected. We will consult some internal accessibility folks on this before deciding on an API. |
Btw, wanted to add that I see two separate but related features here:
What we've mostly been discussing so far is (1), which is much simpler to implement. (2) is more complicated, because the interactions are not well specified for getting into and out of edit mode. For keyboard, the aria spec provides good guidelines, but you would need some way to do the same thing with a mouse (maybe double click? a visual edit button?), a touch screen (long press? a button?), and with a screen reader. You've made a good start here, but this will require further research and testing. I was hoping that we could land a solution to (1) first since it is much simpler, and follow up with (2) in the future once we figure out these interactions. |
@devongovett Gotcha, I'm fine with postponing the In my view
In the meantime, I've worked on a playtest in #7376, which demonstrates interaction event leaks in a lot of RAC’s, not limited to I've also gone ahead and talked through with my team what's actually a roadblock for us at this point, which comes down to the PS: I still think preventing all grid navigation in |
Closes #6037 #5005 #2328 #4957 #5637 #5179 #7121 #1214 #4674 #5003
This PR adds
edit mode
to@react-aria/grid
and RAC<Table />
in addition to generalized support for nested interactive (collection) components inside grid cells or items.It also introduces a new
useGroup()
anduseGroupState()
hook meant to propagate validation and input state to nested interactive components, allowing for more convenience when controlling large sections of an application.✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: