Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor design of autocomplete dropdown #2119

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from

Conversation

tinyoverflow
Copy link
Contributor

@tinyoverflow tinyoverflow commented Feb 15, 2024

Hello,

with this PR, I'd like to suggest a refactor for the autocomplete dropdown. My goal was to make it look a little bit more polished and modern, like the dropdowns in Bitwarden and 1Password.

It shows all informations in a more organized manner instead of just crammed into a single line, which might become too long very easily. In addition to that, it sets some default font styling to try to make it consistent across different websites.

What do you think about this?

Comparison (Before and After)

Before

image

After

SCR-20240216-bqmi

Credits

The drop shadow was borrowed from TailwindCSS.

@droidmonkey
Copy link
Member

Wow this looks awesome!

keepassxc-browser/content/autocomplete.js Outdated Show resolved Hide resolved
@varjolintu
Copy link
Member

varjolintu commented Feb 16, 2024

I'd assume that many users would want to keep the compact view intact, so maybe this could be an optional feature, but enabled by default?
I think it looks great.

@tinyoverflow
Copy link
Contributor Author

tinyoverflow commented Feb 16, 2024

I'd assume that many users would want to keep the compact view intact, so maybe this could be an optional feature, but enabled by default? I think it looks great.

Good point! I've added an option (useCompactMode) to switch to the old view (but styling still applies):
compact

Though I'm not sure about how to properly add the label and description translation accordingly, so it doesn't interfere with Transifex. Can you please help me with that?

image

@varjolintu
Copy link
Member

@tinyoverflow
Copy link
Contributor Author

You need to add a new translation string to https://github.com/keepassxreboot/keepassxc-browser/blob/develop/keepassxc-browser/_locales/en/messages.json.

Thanks, done!

image

@varjolintu
Copy link
Member

varjolintu commented Feb 16, 2024

A couple of things:

The old version had no border radius at the top or bottom, depending if the Autocomplete Menu is positioned on the top or below. Not a real issue, just noted that change.

When looking a page that has a small input field (one of my favourites muusikoiden.net), it can be seen that there's some kind of minimum width where all information fits to the screen:
Screenshot 2024-02-16 at 14 44 00

With the new look it shows like this:
Screenshot 2024-02-16 at 14 43 18

Or with some smaller overlap with GitHub's login page:
Screenshot 2024-02-16 at 14 41 59

Maybe there needs to be some minimum width for the new Autocomplete Menu? And of course some kind of maximum width too where the content cuts off with CSS text-overflow? However, the data shown is not very usable right now.

@tinyoverflow
Copy link
Contributor Author

tinyoverflow commented Feb 16, 2024

@varjolintu Good find! I haven't considered too narrow input fields. I'll work on it later this day.

@tinyoverflow
Copy link
Contributor Author

tinyoverflow commented Feb 16, 2024

One option would be to simply stack the content. What do you think? I think it makes the list bigger than necessary. Otherwise it is ownly shown when the user either enables it explicitly or has items from multiple groups.

image

Another suggestion where I reduced the font size and added some padding:
image

Here's the same on OpenAIs login, for example:
image

@varjolintu
Copy link
Member

Personally I think the original version was better. Stacking more text vertically makes the elements much bigger.

@tinyoverflow
Copy link
Contributor Author

tinyoverflow commented Feb 16, 2024

Personally I think the original version was better.

In what terms? Without the stacking and/or also without the additional padding? How about th reduced font size?

@varjolintu
Copy link
Member

Personally I think the original version was better.

In what terms? Without the stacking and/or also without the additional padding? How about th reduced font size?

With the group text on the upper-right. But I think this could also work with stacking. And it's probably much easier to implement.

@tinyoverflow
Copy link
Contributor Author

tinyoverflow commented Feb 16, 2024

Okey. To be honest, with long titles it looks a little bit... I don't know. It's not bad but I think its not good either.

image

With vertically centered alignment:
image
image

It might work though.

@droidmonkey
Copy link
Member

droidmonkey commented Feb 16, 2024

I personally think there is a bit too much top/bottom padding between items, but otherwise I'm sold

@phoerious
Copy link
Member

I like it, but perhaps we can make the compact variant a middle ground between the new spacious and the old crammed version.

@tinyoverflow
Copy link
Contributor Author

@phoerious Thanks for your feedback! What do you mean? Do you have an idea on how this might look like?

@phoerious
Copy link
Member

Instead of providing a basically unformatted list with names in brackets, try to fit the new layout into a single line with a little but not much more spacing than before.

@tinyoverflow
Copy link
Contributor Author

Done. I think this looks kinda weird, though.

Option 1:

image

Option 2:

image

Default Mode:

image

@droidmonkey
Copy link
Member

droidmonkey commented Feb 25, 2024

I preferred the "Applications" and "Work" labels on the right hand side. The label could be stacked if the width is too narrow?

@varjolintu
Copy link
Member

I guess phoerious meant a middle option like this (compact setting with 12px padding)?:
Screenshot 2024-02-25 at 17 31 10

@varjolintu
Copy link
Member

varjolintu commented Feb 25, 2024

It's possible to do this using flex:
Screenshot 2024-02-25 at 17 58 59

Instead of having a position: absolute in the group I would suggest using simple flex CSS to handle the positioning. Also, use kpxcUI.createElement() where possible.

@tinyoverflow
Copy link
Contributor Author

tinyoverflow commented Feb 25, 2024

Ah, I totally misread phoerious comment. I'll update this PR.

I also prefer the group on the right side on the same line with the title. I also used flexbox for this suggestion. I'm not sure why I removed it, as visible in my recent screenshot:
#2119 (comment)

@tinyoverflow
Copy link
Contributor Author

tinyoverflow commented Feb 25, 2024

I've added it back again. I also think that this looks a lot better.

I'm not sure about the compact mode, though. Just putting it in a single line looks awful to me.

image

@varjolintu
Copy link
Member

@tinyoverflow You also need to add text-overflow etc. to the label if you don't want the elements to overlap.

@phoerious
Copy link
Member

phoerious commented Feb 26, 2024

I would make the compact mode basically the same as the default mode, but remove the group name, move the username to the right, and reduce font size and padding a little. The brackets that we have right now look awful imho. Way too messy and without any visual hierarchy.

@tinyoverflow
Copy link
Contributor Author

tinyoverflow commented Feb 27, 2024

This looks great, imho! I think the compact mode looks even better with the reduced padding, but with default font size.

Normal Mode
image

Compact Mode: Normal Padding
image

Compact Mode: Reduced Padding (I've pushed this one)
image

Compact Mode: Reduced Padding, Reduced Font Size
image

@varjolintu
Copy link
Member

varjolintu commented Feb 27, 2024

The filling does not always work. I often get an error in the console. This can be reproduced if you click the label instead of username.

credential-autocomplete.js:26 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'value')
   at CredentialAutocomplete.itemClick (credential-autocomplete.js:26:68)
   at HTMLDivElement.<anonymous> (autocomplete.js:148:54)

Also if I disable the "Display the group name in autocomplete list when credentials are from different groups." setting, then the new normal mode looks like this:
Screenshot 2024-02-27 at 16 37 38
The Autocomplete Menu position is also much lower now? Here the second input field shows above it.

Plus the "Display group name.." setting has no effect with the compact view.

As I suggested before, these can be changed:
From

const itemGroup = document.createElement('div');
itemGroup.classList.add('kpxcAutocomplete-item__group');
itemGroup.textContent = credential.group;

To

kpxcUI.createElement('div', 'kpxcAutocomplete-item__group', {}, credential.group);

@droidmonkey
Copy link
Member

"Display the group name in autocomplete list when credentials are from different groups." setting

With this improvement to the list view I think this option might be obsolete? Or maybe we default to a more compact view if the group is not displayed.

@varjolintu
Copy link
Member

"Display the group name in autocomplete list when credentials are from different groups." setting

With this improvement to the list view I think this option might be obsolete? Or maybe we default to a more compact view if the group is not displayed.

I think the option still has it uses even with the compact view.

@varjolintu varjolintu modified the milestones: 1.9.0, 1.9.1 Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants