MCPcopy
hub / github.com/adobe/react-spectrum / Inner

Function Inner

packages/react-aria/test/interactions/useFocusWithin.test.js:201–231  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

199 }
200
201 function Inner() {
202 let [show, setShow] = useState(true);
203 return show ? <button onClick={() => setShow(false)}>hide</button> : null;
204 }
205
206 let events = [];
207 let addEvent = e => events.push({type: e.type, target: e.target});
208 let tree = render(
209 <>
210 <Test
211 onFocusWithin={addEvent}
212 onBlurWithin={addEvent}
213 onFocusWithinChange={isFocused => events.push({type: 'focuschange', isFocused})}>
214 <Inner />
215 </Test>
216 <input data-testid="outer" />
217 </>
218 );
219
220 let el = tree.getByRole('button');
221 act(() => el.focus());
222 act(() => el.click());
223 act(() => tree.getByTestId('outer').focus());
224
225 expect(events).toEqual([
226 {type: 'focus', target: el},
227 {type: 'focuschange', isFocused: true},
228 {type: 'blur', target: tree.getByTestId('test')},
229 {type: 'focuschange', isFocused: false}
230 ]);
231 });
232});

Callers

nothing calls this directly

Calls 3

actFunction · 0.85
focusMethod · 0.80
renderFunction · 0.50

Tested by

no test coverage detected