-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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(item): only default slot content wraps #28773
Conversation
4948b27
to
19123bb
Compare
0e99769
to
199a1ce
Compare
4b18d71
to
4b2778e
Compare
...est/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Chrome-linux.png
Outdated
Show resolved
Hide resolved
...n/test/wrap/button.e2e.ts-snapshots/button-wrap-item-button-ios-ltr-Mobile-Firefox-linux.png
Outdated
Show resolved
Hide resolved
...item/test/highlight/item.e2e.ts-snapshots/item-highlight-diff-md-ltr-Mobile-Chrome-linux.png
Outdated
Show resolved
Hide resolved
...ts/item/test/legacy/fill/item.e2e.ts-snapshots/item-fill-diff-md-ltr-Mobile-Chrome-linux.png
Outdated
Show resolved
Hide resolved
...te/test/a11y/note.e2e.ts-snapshots/note-wrapping-label-scale-ios-ltr-Mobile-Chrome-linux.png
Outdated
Show resolved
Hide resolved
* can be displayed in the same space as the | ||
* text grows. | ||
*/ | ||
--inner-min-width: 4rem; |
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 API was only needed to control when the default slot content should stop wrapping within its container and instead have the container wrap to the next line. Since the container no longer wraps to the next line, this API was removed.
Note that this is a private API so it is not a breaking change.
...item/test/highlight/item.e2e.ts-snapshots/item-highlight-diff-md-ltr-Mobile-Chrome-linux.png
Outdated
Show resolved
Hide resolved
...ts/item/test/legacy/fill/item.e2e.ts-snapshots/item-fill-diff-md-ltr-Mobile-Chrome-linux.png
Outdated
Show resolved
Hide resolved
...n/test/wrap/button.e2e.ts-snapshots/button-wrap-item-button-ios-ltr-Mobile-Firefox-linux.png
Outdated
Show resolved
Hide resolved
...est/slotted-inputs/item.e2e.ts-snapshots/item-slotted-inputs-ios-ltr-Mobile-Chrome-linux.png
Outdated
Show resolved
Hide resolved
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.
These screenshot changes are a result of c602b30. This screenshot tries to capture the text wrapping behavior found on native iOS when scaled up to 310%. However, as explained in the PR description, the label and note should really be in the same slot so they can wrap within the container.
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 would developers achieve this? We have notes documented as being slotted in items. The slotted notes with long labels are expanding outside of the viewport height at 310% with these changes:
100% | 310% |
---|---|
vs. inside of the label at 100% they are not clinging to the sides:
100% | 310% |
---|---|
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.
I have the same question; is there a way for developers (or us, for that matter) to detect the current font scale and adjust the markup dynamically?
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 this is an area where we don't have a great solution right now. I'm not aware of how developers can easily have a long note go from the start slot to the default slot when the font size changes apart from putting the content in both slots and selectively hiding one based on the font size using mod()
similar to what we do in datetime.
However, I'd argue having both long notes and long labels in the same item isn't something we should encourage.
According to https://ionicframework.com/docs/api/item#metadata, any notes should be short/to the point such as a count or one/two words.
If developers follow that best practice, they'd get something like this:
Default Scale | 310% Scale |
---|---|
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.
One other idea is you could use a ResizeObserver on an element/container and then do something when that fires. I doubt that would be a very performant way of doing it though.
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.
Looks like the issue Brandy mentioned in #28773 (comment) is still present; some of the notes have their heights massively expanded with this change. Is that supposed to happen? 😆
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.
That's why I suggested having the note in ion-label
so they can wrap and why I mentioned that the test isn't a great example of best practices. The "Really really long note" text is in the start slot, and the default slot is collapsing to account for the width of the start slot. The text inside of the ion-label
is wrapping to the next line, so you essentially have 1 character per line (but the width is so small so you don't see it).
The orange/yellow is the ion-label
.
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.
Ahh, I see. In that case, should we update the test to avoid these long notes in the first place? Wouldn't be the first time we've adjusted tests to match best practices, and this one is particularly sticky since it leads to unnecessarily massive screenshots.
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.
Updated in d9e034c. Mind taking another look?
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.
Muuuch better, thank you!!
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.
LGTM, works as discussed
…ements still wrap
I need to do some clean up and address feedback, so I'll re-request for review when I'm ready 😄 |
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 is the same "wiggling" that we saw in #28146 being undone.
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.
"Range" is part of the default slot, and "End" is part of the end slot. Previously the "end" slot container would wrap to the next line. However, this was removed because it was incorrect. Now both the default and end slots will appear on the same line, and the default slot will shrink.
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 diff is correct. The icons were in start/end slots which now no longer wrap to the next line.
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 diff is correct. The icons were in start/end slots which now no longer wrap to the next line.
I made a few more changes, so re-requesting review. |
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.
Still LGTM, re-request me if the code changes due to this thread.
Issue number: resolves #29033 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> In #28773 I resolved several incorrect behaviors with Items related to text wrapping. However, it looks like I missed the removal of https://github.com/ionic-team/ionic-framework/pull/28146/files#diff-4a1156704dbf45b0dad273b6909b190ca45e4380aa7378ba88d0dd7d48d7d473R37 which caused the issue to persist when adding a label to the end slot. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Removed logic that caused `ion-label` to grow larger than it needed to be | `main` | branch | | - | - | | ![Screenshot 2024-02-13 at 11 20 43 AM](https://github.com/ionic-team/ionic-framework/assets/2721089/3fbddd04-d4b5-474c-ab9c-4d9c6e88f758) | ![Screenshot 2024-02-13 at 11 21 17 AM](https://github.com/ionic-team/ionic-framework/assets/2721089/188eda24-ec6f-4ba7-b3ed-2993d93b1cc7) | ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Dev build: `7.7.2-dev.11707840956.16e27b4c` --------- Co-authored-by: ionitron <[email protected]>
Issue number: resolves #28769
What is the current behavior?
As part of #28146, we allowed text wrapping inside of
ion-item
for accessibility purposes. One of the behaviors we added was to allow start, default, and end slotted containers to wrap to the next line to align with the iOS spec. However, this decision was based on an incorrect assumption.The following screenshot shows the Settings app on iOS:
At the default scale, the blue icon is in the iOS equivalent of the "start" slot, "Bluetooth" is in the default slot, and "On" is in the "end" slot. We incorrectly assumed the same markup was true when scaling the text up. However, at 310% scale the icon, "Bluetooth" text, and "On" text all become part of the default slot in a single container that wraps. You can tell because the bottom border runs underneath the blue icon at 310% whereas it does not at the default scale. This allows the text to wrap underneath the blue icon. When we originally implemented #28146 we thought that this meant the start, default, and end slot containers should wrap to the next line.
I further validated this behavior by creating an app with Swift UI. I created a list of items where each item has the native equivalent of a checkbox in the
start
slot and multipleion-labels
in the default slot of the item:The content within each label wraps within the container, but the containers themselves never wrap to the next line.
Demo code:
What is the new behavior?
ion-label
) will continue to wrap to meet the team's accessibility requirements.Does this introduce a breaking change?
Other information
Dev build:
7.6.5-dev.11704916749.1e64a3a7