fix(item): only default slot content wraps - #28773
Conversation
4948b27 to
19123bb
Compare
0e99769 to
199a1ce
Compare
4b18d71 to
4b2778e
Compare
| * can be displayed in the same space as the | ||
| * text grows. | ||
| */ | ||
| --inner-min-width: 4rem; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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.
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.
Updated in d9e034c. Mind taking another look?
There was a problem hiding this comment.
Muuuch better, thank you!!
thetaPC
left a comment
There was a problem hiding this comment.
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.
This is the same "wiggling" that we saw in #28146 being undone.
There was a problem hiding this comment.
"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.
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.
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. |
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 | | - | - | |  |  | ## 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 <hi@ionicframework.com>





Issue number: resolves #28769
What is the current behavior?
As part of #28146, we allowed text wrapping inside of
ion-itemfor 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
startslot and multipleion-labelsin 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