You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TokenField: scrollCaretIntoView throws "Failed to execute 'setStart' on 'Range'" when the caret is before the trailing <br> #10761
When the value ends with \n, TokenInput renders a trailing <br> as a direct child of the root. When the selection is collapsed at the root level (range.endContainer === root), scrollCaretIntoView passes range.endOffset to getDOMRectPosition. If that offset points at the <br>, this branch runs:
The branch assumes every element child is a token wrapper (<span>token</span>). A <br> has no children, so child.firstChild is null and range.setStart(null, 0) throws.
Steps to reproduce
Render a TokenField with allowsNewlines and a TokenInput.
Type some text, then press Shift+Enter so the value ends with \n.
Use the keyboard (arrow keys) to put the caret before the trailing <br>.
Expected
The caret scrolls into view without errors.
Suggested fix
Only treat an element as a token wrapper when it has the zero width space children. Otherwise fall back to getDOMPosition:
Activity