Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: ion-select without ion-label does not render properly #18773

Closed
mebibou opened this issue Jul 12, 2019 · 8 comments · Fixed by #22221
Closed

bug: ion-select without ion-label does not render properly #18773

mebibou opened this issue Jul 12, 2019 · 8 comments · Fixed by #22221
Labels
help wanted a good issue for the community package: core @ionic/core package type: bug a confirmed bug report
Milestone

Comments

@mebibou
Copy link

mebibou commented Jul 12, 2019

Bug Report

Ionic version:

[x] 4.x

Current behavior:
When setting an ion-select without an ion-label, the select does not take the whole space and therefore looks very odd.

Expected behavior:
The ion-select should just take any available space, just like ion-input does.
It is somewhat fixable by setting in css:

ion-select {
  max-width: 100%;
}

but it should by default just expand

Related code:

<ion-item>
  <ion-icon slot="start" name="car"></ion-icon>
  <ion-select>
    <ion-select-option value="1">Option 1</ion-select-option>
  </ion-select>
</ion-item>

Other information:

Ionic info:

Ionic:

   Ionic CLI                     : 5.2.2 (/.nvm/versions/node/v10.1.0/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.6.1
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   Cordova CLI       : 6.5.0
   Cordova Platforms : ios 4.3.1
   Cordova Plugins   : cordova-plugin-ionic 5.3.1, cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 7 other plugins)

Utility:

   cordova-res : 0.3.0 (update available: 0.6.0)
   native-run  : 0.2.5 (update available: 0.2.7)

System:

   Android SDK Tools : 26.1.1 (/usr/local/Cellar/android-sdk/24.4.1_1)
   ios-deploy        : 1.9.2
   ios-sim           : 6.1.2
   NodeJS            : v10.1.0 (/.nvm/versions/node/v10.1.0/bin/node)
   npm               : 6.10.0
   OS                : macOS Mojave
   Xcode             : Xcode 10.2.1 Build version 10E1001
@ionitron-bot ionitron-bot bot added the triage label Jul 12, 2019
@liamdebeasi
Copy link
Contributor

Thanks for the issue. I believe this is because ion-item is expecting an element to be slotted or in an ion-label. For example, if I do <ion-select slot="end">, ion-select renders fine.

@brandyscarney Thoughts on this? At first glance this seems to be the correct behavior, but I can also understand why this behavior might be seen as incorrect.

@mebibou
Copy link
Author

mebibou commented Jul 12, 2019

adding slot="end" does not solve the issue, as seen on screenshot below:

Screen Shot 2019-07-12 at 2 29 38 PM

When ion-input is used within an ion-item without an ion-label, it works as expected. Others like ion-datetime work as well, only ion-select does not handle this. By default, it should take the whole available space imho

@liamdebeasi
Copy link
Contributor

Good catch, didn't notice that! I agree, this is a bug. We will look into a fix for this.

@liamdebeasi liamdebeasi added package: core @ionic/core package type: bug a confirmed bug report and removed needs: investigation labels Jul 12, 2019
@mebibou
Copy link
Author

mebibou commented Jul 12, 2019

So just to make it complete, here is a sample:

<ion-list>
  <ion-item>
    <ion-icon slot="start" name="car"></ion-icon>
    <ion-select placeholder="Select a Value">
      <ion-select-option value="1">Option 1</ion-select-option>
    </ion-select>
  </ion-item>

  <ion-item>
    <ion-icon slot="start" name="time"></ion-icon>
    <ion-datetime value="2019-01-01"></ion-datetime>
  </ion-item>

  <ion-item (click)="updateFrom()">
    <ion-icon slot="start" name="radio-button-off"></ion-icon>
    <ion-input value="Start"></ion-input>
  </ion-item>
</ion-list>

Screen Shot 2019-07-12 at 2 35 58 PM

I also have set in scss:

ion-select {
  max-width: 100%;
}

but as you can see the placeholder (and the value as well) of the select do not align with the ion-input. I have logged another issue regarding alignment of the ion-datetime

@Slavrix
Copy link

Slavrix commented Dec 13, 2019

was there any progress on this?

@brandyscarney
Copy link
Member

There is a workaround to this, by setting the following (remove the padding if you don't want it aligned left with the input):

ion-select {
  min-width: 100%;
  padding-left: 0;
}

Here's a Codepen: https://codepen.io/brandyscarney/pen/NWPbdyr

Unfortunately issues with workarounds are not at the top of our priority list at the moment but we always appreciate any help to push issues to the top with PRs. I'll add the help wanted label to this which will adds steps on how to contribute. 🙂

The problem is the select & datetime are designed to be with a label so it will take some work to make sure they look good in instances with & without a label and where there are multiple of them in one item (see "Date"):

@brandyscarney brandyscarney added the help wanted a good issue for the community label Dec 16, 2019
@ionitron-bot
Copy link

ionitron-bot bot commented Dec 16, 2019

This issue has been labeled as help wanted. This label is added to issues that we believe would be good for contributors.

If you'd like to work on this issue, please comment here letting us know that you would like to submit a pull request for it. This helps us to keep track of the pull request and make sure there isn't duplicated effort.

For a guide on how to create a pull request and test this project locally to see your changes, see our contributing documentation.

Thank you!

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 6, 2020

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted a good issue for the community package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants