Rename in Place
Write the code, see it run, pass the checks.
The problem
- medium
- Code
- Pro
A list's name shows as a heading, "Groceries", with a "Rename" button. Clicking Rename swaps the heading and the button for a text input labelled "List name", filled in with the current name and already focused. Pressing Enter saves the name, with spaces trimmed from both ends, and shows the heading and Rename button again; pressing Escape cancels and keeps the old name. If the input is empty or only spaces, Enter does nothing and the input stays open.
Your code must pass
- Rename opens a focused input with the current name
- Enter saves the trimmed name
- Escape cancels and keeps the old name
- An empty name isn't saved