evansloan / collectionlog.net

MIT License
17 stars 5 forks source link

Able to search/navigate to any text in typeahead search #53

Closed Napokue closed 1 year ago

Napokue commented 1 year ago

Describe the bug When pressing enter while typing a (partial) username in the "Search users" search, it will navigate to the page "/log/", This results in poor user experience as users are able to navigate to non-existing user collection logs.

Search image

Search result image

Url "https://collectionlog.net/log/test"

What is your username? N.A.

evansloan commented 1 year ago

Being able to search for partial usernames isn't exactly a bug. I wanted to keep the ability to search for whatever, even if it doesn't appear in the typehead, due to 1 and 2 character names. The call to the API for the typeahead isn't made until at least 2 characters are typed in the search box, and then the typeahead appears on the 3rd character. I haven't looked to see if any 1 or 2 character names exist on the site, but I'd like to keep that functionality around. We could decrease the character limit on the typeahead but I'd rather keep the load as light as possible on the API.

There is still a bug here though, being the display of "undefined's Collection log". There is supposed to be an error message that displays "Unable to find collection log for user [username]" but that doesn't seem to display unless a successful search was performed beforehand. Most likely due to the collection log object stored in the state being undefined prior to a successful search.

Napokue commented 1 year ago

Maybe I was not describing the issue properly, but the issue specifically is when pressing the enter key the onSearch function will be invoked, even if the user does not exist, it will navigate.

A solution that I am currently prototyping would be to only allow enter to be pressed when the username is existing in the database.

Currently we have a naïve approach where we always navigate to a page without checking if the username exists. I think it would be better to not display a page that the specific text is not a user, as: 1) It introduces complexity in the collection log component that we are able to contain in the header component by for instance using my solution. 2) The user is being navigated without their intention to, which causes a disruption in their flow.

Napokue commented 1 year ago

I have created #54. Let me know what you think of it and if this is something we want.

Napokue commented 1 year ago

Forgot to add the fix text in the PR. Closing now.