Skip to content

fix(alert): radio and checkbox labels wrap to next line - #27898

Merged
liamdebeasi merged 8 commits into
feature-7.3from
FW-3688
Aug 1, 2023
Merged

fix(alert): radio and checkbox labels wrap to next line#27898
liamdebeasi merged 8 commits into
feature-7.3from
FW-3688

Conversation

@liamdebeasi

@liamdebeasi liamdebeasi commented Jul 31, 2023

Copy link
Copy Markdown
Contributor

Issue number: resolves #17269


What is the current behavior?

Long radio and checkbox labels truncate with ellipsis instead of wrapping to the next line. This makes the label hard to understand because users cannot read the entire label.

What is the new behavior?

  • Labels now wrap to the next line instead of truncating.

Note: Some of the screenshots may show wider alerts than before. This is the correct behavior. When rendering text, the browser will try to render as much text on a single line as it can. Since our alerts can expand in width, the alert wrapper will expand in width (up to the max width) to accommodate this text. Once the the wrapper is at the max width, text will then wrap to the next line.

For example, you may notice the MD alert increasing to 280px in width:

$alert-md-max-width: 280px !default;
.

There should be no visual diff for alerts with text that would not normally wrap to the next line.

This was not happening before because we did not allow text to wrap to the next line.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions github-actions Bot added the package: core @ionic/core package label Jul 31, 2023

.alert-tappable {
height: $alert-ios-tappable-height;
min-height: $alert-ios-tappable-height;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ticket notes that we should set height: auto, but I found that created some undesired diffs on radios/checkboxes with short text. I found that min-height gets us to the same desired result without the additional diffs for short text.

width: 100%;
height: 100%;

min-height: inherit;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this the button inner may have visual diffs since the height is no longer fixed at 48px

appearance: none;

contain: strict;
contain: content;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, each radio/checkbox will still be sized at 48px. This change allows the height of the element to increase as the text wraps.

@liamdebeasi
liamdebeasi requested review from a team and brandyscarney July 31, 2023 17:21
@liamdebeasi
liamdebeasi marked this pull request as ready for review July 31, 2023 17:21

@brandyscarney brandyscarney left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. I am wondering if we shouldn't separate out the wrapping example. Do we have an existing screenshot for checkbox/radio in an alert without wrapping?

Comment thread core/src/components/alert/test/basic/index.html Outdated
Comment thread core/src/components/alert/test/basic/index.html Outdated

@brandyscarney brandyscarney left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! The changes to min-height and contain make sense.

@liamdebeasi
liamdebeasi changed the base branch from main to feature-7.3 August 1, 2023 14:54
@github-actions github-actions Bot added package: angular @ionic/angular package package: vue @ionic/vue package package: react @ionic/react package labels Aug 1, 2023
@github-actions github-actions Bot removed package: angular @ionic/angular package package: vue @ionic/vue package package: react @ionic/react package labels Aug 1, 2023
@liamdebeasi
liamdebeasi merged commit 0d3127a into feature-7.3 Aug 1, 2023
@liamdebeasi
liamdebeasi deleted the FW-3688 branch August 1, 2023 15:48
github-merge-queue Bot pushed a commit that referenced this pull request Oct 25, 2023
Issue number: resolves #28406

---------

<!-- 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 #27898 we
updated the radio and checkbox labels to wrap to the next line instead
of truncate. However, we did not consider long words. As a result, long
words run outside of the container.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- The radio and checkbox labels now break on words too in addition to
white space characters.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

---------

Co-authored-by: ionitron <hi@ionicframework.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ion-select with long text options doesn't render properly on ios and md

3 participants