Repository navigation
feat(segment): display segment as a grid and add an ellipsis to overflowing text in a segment button - #27457
Merged
Conversation
|
|
brandyscarney
marked this pull request as ready for review
May 11, 2023 22:32
averyrousseau
self-requested a review
May 12, 2023 17:59
averyrousseau
suggested changes
May 12, 2023
brandyscarney
marked this pull request as draft
May 17, 2023 16:49
Member
Author
|
Changed the base branch to |
Contributor
|
@brandyscarney Can you rebase off |
Member
Author
|
Separated the screenshots out to this PR: https://github.com/ionic-team/ionic-framework/pull/27531/files Made this PR against feature-7.1. Requesting a re-review on this please! |
liamdebeasi
reviewed
May 23, 2023
liamdebeasi
left a comment
Contributor
There was a problem hiding this comment.
Only noticing one (possibly) unintentional change (See below). Otherwise this is looking really great.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: resolves #16532
What is the current behavior?
Text that is too long to fit in a segment button does not ellipsis, instead it centers all of the text and cuts it off at the beginning and end of the text.
What is the new behavior?
Text that is wider than the segment button will now add an ellipsis and cut the text off instead of horizontally centering the text and overflowing the button (while being cut off visually).
While researching how to fix this issue I discovered that the button text was not properly overflowing when it should due to a limitation of flex. I was able to mock segments using divs and see that certain buttons were adding an ellipsis when there was room to grow. This is due to a combination of using
flex-basis: 0on the segment buttons andwidth: autoon the segment inside of a toolbar. This blog sums it up well, but it is not something I could work around with segment set asdisplay: flex. When I changed the mocked segment to usedisplay: grid, it allowed the text to properly grow, while overflowing and adding an ellipsis when it couldn't grow. This can be seen in my Codepen example.As a result, I made the following updates:
ion-segmenttodisplay: grid(display: inline-gridcould not be used because the highlight was not properly aligned to the bottom of a toolbar formdmode)max-widthfor Material Design segment buttons to the parent segment by usinggrid-auto-columns: minmax(auto, $segment-button-md-max-width);. This is necessary for the buttons to properly center inside of the grid when they all hit the max-width (360px at the moment).grid-row: 1on the host segment button. This tells the segment buttons to stay on the same row.max-width: 100%andoverflow: hiddenon the native button. This allows the text itself to ellipsis.ion-labelelements in the segment buttonsDoes this introduce a breaking change?
Other information
High-level changes between main and this branch
mainFW-3401