-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix: Adjusting the width of dropdown #18059
Conversation
140, | ||
values.reduce(function(a, b) { | ||
return a.length > b.length ? a : b | ||
}, '').length * 8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how did you choose the number eight?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not going to lie, it looked the best in the UI. I tried a few numbers, and 8 looked ideal for the px
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the intent to find out what the max width of the longest variable could be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the intent is find the longest variable, then take its length and determine how much width in px would be needed to display it
@alexpaxton do you have any fancy tricks for measuring text up your sleeve? i have a fear that we're tightly coupling a font choice to system behavior here |
If we style the dropdown items to be in the monospace font then all characters will be the same width, and more predictable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually when there's measuring of text to be done, you send the text to a hidden span floating off screen and measure the span, and that decouples font size / face / letterspacing issues from the measurement, but i can't see a favorable ROI on using that technique unless it's done in clockface for all the things
8baff1c
to
6432bce
Compare
This will make it so the width of the dropdown will adjust to the longest variable name
Updating font
fix prettier
6432bce
to
e17dc2a
Compare
This will make it so the width of the dropdown will adjust to the longest variable name
Closes #18021
Describe your proposed changes here.
Ive done a simple math problem that determines the longest length in the values and makes that the width px