KOEN
All notes
UI & INTERACTION

When the clear button disappears, where does typing go?

After reading UI SDK’s focus-recovery example, I made two small HTML search fields. Clearing their text and removing a button did not, by themselves, leave a place for the next word.

A hand returning a brass ring to a paper search field beside a detached coral button

The empty field came back

I made two search fields with an initial value of old. Each has a clear button. With keyboard focus on that button, pressing Enter clears the text and removes the button. With nothing left to clear, the small interface no longer needs it.

Then I typed new. One search field stayed empty. The other received new.

The difference was not in the deleted text. The second handler called focus() on the input after removing the button. The first stopped after clearing the value and removing the control.

I also inspected document.activeElement. It was BODY in the first case and the input in the second. Having an empty field on screen did not send the next keystrokes there.

This was a separate plain-HTML fixture checked in Chromium 158.0.8127.36, not a comparison made by installing UI SDK. It covered one sequence: focus the clear button, press Enter, then type the English word new. It was not a recreation of an incident in a real service.

The prompt for this little screen was Vercel Labs’ UI SDK example. The library composes behaviors such as focus, selection and dismissal rather than supplying only finished visual components. Its search-field clear button caught my attention.

The example both makes the clear button conditional on a nonempty value and sets an input fallback through createFocusRecovery. It addresses where the focus should go as well as when the button should disappear.

One more step after clearing

I would probably begin by checking that clearing worked. The value is empty and the button is gone; the screen looks finished. Trying the next word revealed another thing to check.

MDN describes focus() as setting focus on a specified element that can receive it. Focus concerns the default recipient of keyboard input. Changing a value and moving focus are separate actions, and this small example made that separation visible.

For someone about to search again, clearing a field need not mean abandoning the search. They may simply want a different word. The next character follows the empty field, even though the button is no longer there.

That makes me want to inspect more than the frame immediately after pressing the button. Was the button focused? What receives input after it disappears? Can another word be entered? The two screens diverged at that next action.

This does not mean sending focus to an arbitrary input every time. The destination should fit the next task and still exist. Closing an entire screen and clearing only its search text need not lead to the same place.

The fixture did not verify every combination of mobile input, an input-method editor or a screen reader. Nor did it evaluate the quality of UI SDK’s focus handling as a whole. It established a narrower difference between clearing a value and preserving the next typing target in the two screens I made.

When reviewing a report that a screen has been fixed, I would like one more request: enter another search term after clearing. Rather than just hearing that the screen is clean, I would like to see a fresh word enter the empty field.

The clear button can disappear. I would like the next word to still have somewhere to go.

Sources

All notes