Skip to content

Commit

Permalink
fix(item): only default slot content wraps (#28773)
Browse files Browse the repository at this point in the history
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 #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 |
| - | - |
|
![IMG_3133](https://github.com/ionic-team/ionic-framework/assets/2721089/8b55bd1d-f7a8-4fec-bda4-d1bb12f50d34)
|
![IMG_3134](https://github.com/ionic-team/ionic-framework/assets/2721089/92e8a196-36e4-47d6-a4e5-a0e991c78d0d)
|

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>
  • Loading branch information
liamdebeasi and Ionitron committed Jan 26, 2024
1 parent 720a3ce commit 9448783
Show file tree
Hide file tree
Showing 39 changed files with 8 additions and 76 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 2 additions & 70 deletions core/src/components/item/item.scss
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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
// --------------------------------------------------

Expand Down Expand Up @@ -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;
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions core/src/components/note/test/a11y/note.e2e.ts
Expand Up @@ -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>
`,
Expand Down

0 comments on commit 9448783

Please sign in to comment.