Fixes an issue where if the elements were re-ordered or changed significantly, we wouldn't be able to re-attach focus. Worse so, we never check if the element exists before trying to focus it, so we would get an error!
This PR also fixes an error where the scroll position would be reset when typing in an input.
Screenshots (Before)
When interacting with an input that has <span>-</span> for every letter in the input. This is what happens when typing and then deleting (this is the integration test app, which can be run locally with npm run test:app):
The first set of errors is because we are trying to setSelectionRange on a <span>, the second error is because after deleting no element exists at the index that the <input> was on.
Summary
Fixes an issue where if the elements were re-ordered or changed significantly, we wouldn't be able to re-attach focus. Worse so, we never check if the element exists before trying to focus it, so we would get an error!
This PR also fixes an error where the scroll position would be reset when typing in an input.
Screenshots (Before)
When interacting with an input that has
<span>-</span>
for every letter in the input. This is what happens when typing and then deleting (this is the integration test app, which can be run locally withnpm run test:app
): The first set of errors is because we are trying tosetSelectionRange
on a<span>
, the second error is because after deleting no element exists at the index that the<input>
was on.Screenshots (After)
No errors :tada:
Checklist