Commit 5a40712
authored
fix(assignee-selector): split autofocus inp cost over multiple frames (#64165)
This PR reduces the INP impact of the autofocus react attribute by
deferring the focus event until next frame.
Calling [.focus](https://gist.github.com/paulirish/5d52fb081b3570c81e3a)
causes layout thrashing which causes UI jank. We are currently able to
observe this using browser profiling where a lot of the call stacks
point towards a .focus perf culprit.

Having looked at prod profiles and react source, the function
responsible for calling .focus is
[commitMount](https://github.com/facebook/react/blob/2477384650bd184d3ac4a881130118f2636f8551/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js#L676),
called during a finalizeInitialChildren. I did not verify when exactly
this is called, but from the profiling data, this always appears to
always be the last function in the call stacks when committing changes
to the DOM.
The PR mitigates the sync nature of the .focus call by removing the
autofocus attribute and scheduling the autofocus to be performed in the
next browser event loop tick, yielding to the engine and splitting the
cost over two multiple browser frames.1 parent d1b76c5 commit 5a40712
File tree
1 file changed
+28
-3
lines changed- static/app/components/dropdownAutoComplete
1 file changed
+28
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
25 | 45 | | |
26 | 46 | | |
27 | 47 | | |
| |||
121 | 141 | | |
122 | 142 | | |
123 | 143 | | |
124 | | - | |
| 144 | + | |
125 | 145 | | |
126 | 146 | | |
127 | 147 | | |
| |||
343 | 363 | | |
344 | 364 | | |
345 | 365 | | |
346 | | - | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
347 | 372 | | |
348 | 373 | | |
349 | 374 | | |
350 | 375 | | |
351 | 376 | | |
352 | | - | |
| 377 | + | |
353 | 378 | | |
354 | 379 | | |
355 | 380 | | |
| |||
0 commit comments