fix(item): only default slot content wraps (#28773)
Issue number: resolves #28769 --------- <!-- 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. --> As part of https://github.com/ionic-team/ionic-framework/pull/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: | default scale | 310% scale | | - | - | | <img width="1170" alt="Frame 4" src="https://github.com/ionic-team/ionic-framework/assets/2721089/462ef153-a060-41c8-9a00-f0aad17839be"> | <img width="1170" alt="Frame 5" src="https://github.com/ionic-team/ionic-framework/assets/2721089/f047f880-7b80-4710-939b-96da075fbbf9"> | 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 multiple `ion-labels` in the default slot of the item: | Default Scale | 310% Scale | | - | - | |  |  | The content within each label wraps within the container, but the containers themselves never wrap to the next line. Demo code: ```swift import SwiftUI struct ContentView: View { struct Item: Identifiable, Hashable { let id = UUID() } private var items = [ Item(), Item(), Item(), Item(), Item() ] @State private var multiSelection = Set<UUID>() var body: some View { NavigationView { List(items, selection: $multiSelection) {_ in HStack { Text("Column 1 with really long text") Text("Column 2 with really long text") Text("Column 3 with really long text") Text("Column 4 with really long text") } } .toolbar { EditButton() } } Text("\(multiSelection.count) selections") } } #Preview { ContentView() } ``` ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - This PR removes the ability for the start, default, and end slot containers to wrap to the next line. This behavior aligns with pre-v7.6.0 behaviors. The containers inside of the default slot will not wrap to the next line. However, content within each container (such as text within an `ion-label`) will continue to wrap to meet the team's accessibility requirements. ## 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.6.5-dev.11704916749.1e64a3a7` --------- Co-authored-by: ionitron <hi@ionicframework.com>
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
@ -51,15 +51,6 @@
|
||||
* @prop --highlight-color-valid: The color of the highlight on the item when valid. Only applies to inputs and textareas using the legacy form syntax. DEPRECATED: Highlights can be styled on `ion-input` or `ion-textarea` when using the modern form syntax.
|
||||
* @prop --highlight-color-invalid: The color of the highlight on the item when invalid. Only applies to inputs and textareas using the legacy form syntax. DEPRECATED: Highlights can be styled on `ion-input` or `ion-textarea` when using the modern form syntax.
|
||||
*/
|
||||
|
||||
/**
|
||||
* We change the minimum width as the
|
||||
* font size changes. Using a fixed minimum
|
||||
* width means that fewer and fewer characters
|
||||
* can be displayed in the same space as the
|
||||
* text grows.
|
||||
*/
|
||||
--inner-min-width: 4rem;
|
||||
--border-radius: 0px;
|
||||
--border-width: 0px;
|
||||
--border-style: solid;
|
||||
@ -230,11 +221,6 @@
|
||||
display: flex;
|
||||
position: relative;
|
||||
|
||||
// Flex wrap is required here in order to wrap
|
||||
// the start slot + .item-inner content that
|
||||
// doesn't fit on the same line
|
||||
flex-wrap: wrap;
|
||||
|
||||
align-items: inherit;
|
||||
justify-content: inherit;
|
||||
|
||||
@ -258,11 +244,6 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
// TODO(FW-5289): remove
|
||||
:host(.item-legacy) .item-native {
|
||||
flex-wrap: unset;
|
||||
}
|
||||
|
||||
.item-native::-moz-focus-inner {
|
||||
border: 0;
|
||||
}
|
||||
@ -307,34 +288,13 @@ button, a {
|
||||
// This is required to work with an inset highlight
|
||||
position: relative;
|
||||
|
||||
// This flex property is required in order to make
|
||||
// the elements wrap when there is a slotted start
|
||||
// element and a label
|
||||
flex: 1 0 0;
|
||||
flex: 1;
|
||||
|
||||
flex-direction: inherit;
|
||||
|
||||
// Flex wrap is required here in order to wrap
|
||||
// .input-wrapper content + the end slot that
|
||||
// doesn't fit on the same line
|
||||
flex-wrap: wrap;
|
||||
|
||||
align-items: inherit;
|
||||
align-self: stretch;
|
||||
|
||||
/**
|
||||
* The min-width defines when the
|
||||
* content in the default slot should
|
||||
* stop wrapping/truncating within its own
|
||||
* container. At this point the entire
|
||||
* container will wrap to the next line.
|
||||
*/
|
||||
min-width: var(--inner-min-width);
|
||||
|
||||
// Max width must be set to 100%, otherwise the
|
||||
// elements will overflow this container instead
|
||||
// of wrapping
|
||||
max-width: 100%;
|
||||
min-height: inherit;
|
||||
|
||||
border-width: var(--inner-border-width);
|
||||
@ -346,15 +306,6 @@ button, a {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
// TODO(FW-5289): remove
|
||||
:host(.item-legacy) .item-inner {
|
||||
flex: 1;
|
||||
|
||||
flex-wrap: unset;
|
||||
|
||||
max-width: unset;
|
||||
}
|
||||
|
||||
// Item Bottom
|
||||
// --------------------------------------------------
|
||||
|
||||
@ -448,38 +399,19 @@ button, a {
|
||||
// This flex property is required in order to keep
|
||||
// the label from shrinking when there are wide
|
||||
// elements next to it
|
||||
flex: 1 0 auto;
|
||||
flex: 1;
|
||||
|
||||
flex-direction: inherit;
|
||||
|
||||
// Flex wrap is required here in order to wrap
|
||||
// content in the default slot (such as a label
|
||||
// and a button) that doesn't fit on the same line
|
||||
flex-wrap: wrap;
|
||||
|
||||
align-items: inherit;
|
||||
align-self: stretch;
|
||||
|
||||
// Max width must be set to 100%, otherwise the
|
||||
// elements will overflow this container instead
|
||||
// of wrapping
|
||||
max-width: 100%;
|
||||
|
||||
text-overflow: ellipsis;
|
||||
|
||||
overflow: inherit;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
// TODO(FW-5289): remove
|
||||
:host(.item-legacy) .input-wrapper {
|
||||
flex: 1;
|
||||
|
||||
flex-wrap: unset;
|
||||
|
||||
max-width: unset;
|
||||
}
|
||||
|
||||
:host(.item-label-stacked),
|
||||
:host(.item-label-floating) {
|
||||
align-items: start;
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 193 KiB After Width: | Height: | Size: 196 KiB |
Before Width: | Height: | Size: 230 KiB After Width: | Height: | Size: 238 KiB |
Before Width: | Height: | Size: 167 KiB After Width: | Height: | Size: 170 KiB |
Before Width: | Height: | Size: 194 KiB After Width: | Height: | Size: 198 KiB |
Before Width: | Height: | Size: 234 KiB After Width: | Height: | Size: 239 KiB |
Before Width: | Height: | Size: 168 KiB After Width: | Height: | Size: 171 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 20 KiB |
@ -72,33 +72,33 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
|
||||
|
||||
<ion-list>
|
||||
<ion-item>
|
||||
<ion-note slot="start">Really really long note</ion-note>
|
||||
<ion-note slot="start">123</ion-note>
|
||||
<ion-label>Label</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label>Label</ion-label>
|
||||
<ion-note slot="end">Really really long note</ion-note>
|
||||
<ion-note slot="end">123</ion-note>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-note slot="start">Note</ion-note>
|
||||
<ion-note slot="start">123</ion-note>
|
||||
<ion-label>Really really long label</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label>Really really long label</ion-label>
|
||||
<ion-note slot="end">Note</ion-note>
|
||||
<ion-note slot="end">123</ion-note>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-note slot="start">Really really long note</ion-note>
|
||||
<ion-note slot="start">123</ion-note>
|
||||
<ion-label>Really really long label</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label>Really really long label</ion-label>
|
||||
<ion-note slot="end">Really really long note</ion-note>
|
||||
<ion-note slot="end">123</ion-note>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
`,
|
||||
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 49 KiB |
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 42 KiB |