[RAC] Table typeahead captures all keyboard input, leaving none for nested Inputs #6037
Open
Description
Provide a general summary of the issue here
I've got a table like this, where the inputs can't capture a single keystroke, because the table hungrily swallows them all:
import { Cell, Column, Input, Row, Table, TableBody, TableHeader } from "react-aria-components";
const items = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").map((letter) => ({id:letter}));
export default function Home() {
return (
<Table>
<TableHeader>
<Column isRowHeader>Name</Column>
<Column>Value</Column>
</TableHeader>
<TableBody items={items}>
{(row) => (
<Row>
<Cell>{row.id}</Cell>
<Cell><Input type="text" /></Cell>
</Row>
)}
</TableBody>
</Table>
);
}
🤔 Expected Behavior?
I'd love for the inputs to Just Work™ in a situation like this.
😯 Current Behavior
Screen.Recording.2024-03-10.at.10.02.48.PM.mov
💁 Possible Solution
- Is there a good reason for
useTypeSelect
to be using the capture phase? If it used the bubble phase, the inputs themselves could choose if/when to stop propagation. - This is a bit more blunt, but why not allow typeahead to be disabled on tables?
useSelectableCollection
already takes adisallowTypeAhead
prop, but there's not currently a way to drill that all the way down through<Table>
→useTable
→useGrid
→useSelectableCollection
.
🔦 Context
#1214 is a 3-year-old ticket that mentions that tables swallow spaces, but somehow fails to mention that tables can also swallow all keystrokes as long as the input is matching the value of a row header.
🖥️ Steps to Reproduce
https://codesandbox.io/p/sandbox/old-voice-k5n9p4
Version
"react-aria-components": "^1.1.1"
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
macOS
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
Metadata
Assignees
Labels
No labels