01 · Empty titles can be saved
Entering only spaces creates a bookmark with no visible name.
Suggestion: Trim the input, then check for an empty title before saving.
Public demo · Fictional bookmark app
Validate empty titles first, then deduplicate the sorting logic.
Entering only spaces creates a bookmark with no visible name.
Suggestion: Trim the input, then check for an empty title before saving.
The saved-bookmarks and search pages each maintain the same time-based sorting code.
Suggestion: Extract a small function and call it from both places.
This fictional code illustrates the change. No real project has been modified.
function normalizeTitle(value: string): string {
const title = value.trim();
if (!title) throw new Error("Enter a bookmark title");
return title;
}Check how saving behaves with an empty string, spaces only, and a valid title.