-
Notifications
You must be signed in to change notification settings - Fork 0
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 option name truncation on StyledSelectOption component #56
Fix option name truncation on StyledSelectOption component #56
Conversation
… fits the component properly at all viewport widths; update snapshots/tests
|
||
@media (min-width: 769px) { | ||
.root { | ||
font-size: 1.025rem; |
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.
This was just kind of a fly in the ointment - minimal visible difference but messed with the truncation.
import classNames, { type Argument } from 'classnames' | ||
import { measureText } from '../../utils/measureText' |
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.
If I was going to do this over I'd change it to a default export but it doesn't matter enough to make the change in all three places it's imported lol.
…l tangible benefit while messing with the option name truncation
d675638
to
ccf01f2
Compare
Context
Fix whatever is going on with StyledSelect
In #55, I set up the
StyledSelect
component to dynamically truncate its header text, making sure the text is long enough for the containing element while preventing it from overflowing or wrapping. However, what I overlooked is that theStyledSelectOption
component also truncates itsoptionName
prop for display. This resulted in continued wrapping in that component after #55 was merged.Changes
measureText
function since the same code is now used in 3 placesuseSize
hook inStyledSelectOption
component to measure the width of the element and truncate text accordinglyRequired Tasks
Add/update automated testsAdd/update Storybook storiesAdd/update docsConsiderations
As mentioned in #55, use of the
canvas
element to measure the width of the text comes at a cost: thenode-canvas
package that enables this element to be used server-side - i.e., in headless automated tests - does not supportworker_threads
, which we require due to dependencies of our toolset. Thenode-canvas
maintainers have indicated they will try to add this support soon, so instead of removing affected tests, I have set them to be skipped, as well as updating the titles of the tests to reflect the changes. Hopefully a newnode-canvas
will be released soon that offers this support.Manual Test Cases
Dropdown
The width of the dropdown changes when the viewport width is between 320 and 480 pixels. For viewports 481px and wider, the width of the dropdown is fixed. For this reason, you'll need to view the changes at numerous viewport widths in the 320px-480px range, but testing at viewport widths larger than 481px isn't really necessary - if it works at 481px, it works at all the widths higher than that.
StyledSelect
componentList Edit Form
Because changes have been made to the
ListEditForm
component, you will need to try editing a shopping list title to make sure that the changes haven't broken the component. No changes to appearance or functionality are expected.Screenshots and GIFs
Note that, although changes were made to the
ListEditForm
component, those changes don't affect the appearance or functionality of that component and as such don't need to be tested here.Mobile Viewports
320px
480px
Larger Viewports
As mentioned above, the width of the dropdown is fixed at viewport widths 481px and higher, so there's no need to provide more than one of these really.
481px
601px