Examples

Folder path input

Built with the mantine-combobox skill

Save document

Choose a folder in your workspace. Type a path or complete it one folder at a time.

Build a "Save to" input for a document editor: the user types the folder path where the document is saved, like projects/web/forms, with completion one folder at a time, like in a shell.

Data:

  • a hard-coded workspace tree of about 40 folders, up to 4 levels deep, each with the number of documents it holds

Completion:

  • the dropdown lists the subfolders of the folder the path points to, filtered by the segment being typed: names that start with it first, then names that contain it
  • a header in the dropdown shows the folder being listed ("projects / web")
  • Tab or Enter on a highlighted folder completes the segment and appends /, then lists that folder's subfolders; ArrowRight does the same when the caret is at the end of the text
  • typing / after the exact name of a folder also moves into it
  • Backspace right after a / removes the whole last segment and goes up one level
  • each option shows a folder icon, the name and its document count; a folder without subfolders has no "go inside" hint
  • when the typed segment matches no folder, the only option is "Create folder “name” in projects / web"; created folders are added to the tree, marked as new, and can be entered like the others
  • folder names may contain letters, numbers, spaces, - and _; anything else shows an error

Value:

  • the path is valid when every segment is an existing folder; the field shows an error on blur when the path does not exist
  • "Save" is disabled until the path is valid; saving shows a short notification ("Saved to projects / web / forms") and displays the saved path and the folders created in this session as JSON under the input
  • the input starts with the path of the last saved location (documents/drafts)

Write tests for the component.