MCPcopy Create free account
hub / github.com/adobe/react-spectrum / Example

Function Example

packages/@react-spectrum/s2/test/TableView.test.tsx:146–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144
145 it("if the previously focused cell's row is disabled, the focus should still be restored to the cell when the disabled behavior is changed and the user navigates to the collection", async () => {
146 function Example() {
147 let [disabledBehavior, setDisabledBehavior] = useState<DisabledBehavior>('selection');
148 return (
149 <>
150 <button>Before</button>
151 <TableView
152 aria-label="Dynamic table"
153 disabledBehavior={disabledBehavior}
154 disabledKeys={['2']}>
155 <TableHeader columns={columns}>
156 {column => <Column {...column}>{column.name}</Column>}
157 </TableHeader>
158 <TableBody>
159 <Row id="1">
160 <Cell>Foo 1</Cell>
161 <Cell>Bar 1</Cell>
162 <Cell>Baz 1</Cell>
163 <Cell>Yah 1</Cell>
164 </Row>
165 <Row id="2">
166 <Cell>Foo 2</Cell>
167 <Cell>Bar 2</Cell>
168 <Cell>Baz 2</Cell>
169 <Cell>Yah 2</Cell>
170 </Row>
171 <Row id="3">
172 <Cell>Foo 3</Cell>
173 <Cell>Bar 3</Cell>
174 <Cell>Baz 3</Cell>
175 <Cell>Yah 3</Cell>
176 </Row>
177 </TableBody>
178 </TableView>
179 <button onClick={() => setDisabledBehavior('all')}>After</button>
180 </>
181 );
182 }
183
184 let {getAllByRole, getByRole} = render(<Example />);
185 await user.click(document.body);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected