question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Bug Report

Ionic version: 4.0.0

Current behavior: Long ion-select-option won’t be displayed properly in the pop-up compared to ionic 3

Expected behavior: Long ion-select-option should properly size the item and allow the user to see all the text

Steps to reproduce:

  1. Create ionic 4 project
  2. Add <ion-select> with 2 options: 1 with very long text and 1 with short text
  3. Open the ion select. The first element should display only 30-40 characters and hyphens

ios example image

md example image

if you do the same with an ionic 3 project, this should show properly both of the lines:

ios example image

md example image

Other information:

Setting white-space: normal; on the alert-radio-label does help a bit to show longer text but still it is maximized to 2 lines. Ionic info:

Ionic:
   ionic (Ionic CLI)             : 4.9.0 (C:\Users\Cactus\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.0.0
   @angular-devkit/build-angular : 0.12.3
   @angular-devkit/schematics    : 7.2.3
   @angular/cli                  : 7.2.3
   @ionic/angular-toolkit        : 1.2.2

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : none
   Cordova Plugins       : no whitelisted plugins (0 plugins total)

System:

   NodeJS : v8.12.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 10

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

33reactions
plchampignycommented, Mar 8, 2019

Yup, sorry to the delay in the response. Here’s our workaround:

// Applies a text wrap on ion options
.alert-tappable.alert-radio {
    height: auto;
    contain: content;
}

.alert-radio-label.sc-ion-alert-md,
.alert-radio-label.sc-ion-alert-ios {
    white-space: normal;
}
5reactions
elwinschmitzcommented, Nov 4, 2021

For people that experience this same issue on Ionic v5, here is my workaround:

Styles to put in global.scss:

//  Force text-wrap on <ion-select>
ion-select::part(placeholder),
ion-select::part(text) {
  white-space: normal !important;
}
// Force text-wrap on <ion-select-option>'s when shown in an Ionic Alert
ion-alert.select-alert {
  // These widths are pretty arbitrary, so you're use-case(s) could required different widths:
  --width: 33vw !important;
  --max-width: 66vw !important;

  .select-interface-option .alert-radio-label,
  .select-interface-option .alert-checkbox-label {
    white-space: normal !important;
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

[IONIC] ion-select long option viewing issue | by Rajesh Mishra
I have recently faced an issue with long select options. When the option in the select is very long, let say a sentence...
Read more >
ionic-4 Text-wrap on ion-select-option - Stack Overflow
On Ionic 5, the only thing that worked for me was: .alert-radio-label.sc-ion-alert-md { white-space: normal !important; }.
Read more >
Ion-select text wrap not working-How to overwrite the white ...
Issue: ion-select with long text options doesn't render properly on ios and md ... Bug Report Ionic version: 4.0.0 Current behavior: Long ion- ......
Read more >
Ionic-4 Text-Wrap On Ion-Select-Option - ADocLib
if you are with Ionic 4 then just use class"ion-text-wrap" for wrapping text anywhere in element. By default, select uses the AlertController API...
Read more >
Ionic 5 UI Components Properties - Appery.io
Select ; Spinner; Text; Textarea; Toggle; Toolbar.. Custom UI Components. Note that you are not limited to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found