Skip to content

bug(ion-select): No longer possible to set margin: auto on ::part(icon) #27392

Closed as not planned

Description

@lincolnthree

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

When using the modern form syntax, it is no longer possible to control the margin of the icon part using automatically calculated margins when the width of the ion-select is set larger than its content (such as 100% or a fixed pixel amount like 150px):

image

One used to be able to modify the spacing of the 'icon' from the text using the shadow part and an automatic margin. But now it seems there's a new style on the .native-wrapper that prevents modifying the margin using auto in the modern form syntax. Setting a fixed pixel margin on the icon works fine.

Code that should work:

ion-select::part(icon) {
  margin-left: auto;
  margin-right: 15px;
}

Expected Behavior

I expect the Modern form control to be customizable the same way such that full-width select inputs can be styled to match our application theme. Setting the .native-wrapper to width: 100% in the element debugger also resolves this. (And does not appear to break other styling.)

image

Steps to Reproduce

  1. Run sample app.
  2. View tab 1.
  3. Enjoy

Code Reproduction URL

https://github.com/lincolnthree/ionic-bugs/tree/issue-27392

Ionic Info

Ionic:

Ionic CLI : 7.0.1 (/Users/lincoln/.nvm/versions/node/v16.14.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 7.0.5
@angular-devkit/build-angular : 15.2.6
@angular-devkit/schematics : 15.2.6
@angular/cli : 15.2.6
@ionic/angular-toolkit : 9.0.0

Additional Information

No response

Activity

  1. liamdebeasi commented on May 4, 2023

    @liamdebeasi
    Contributor

    Thanks for the report. I can reproduce this, though the behavior here is intentional. The "native-wrapper" is designed to take up only as much width as it needs to match the iOS and MD specs. The margin: auto styles worked in Ionic v6 due to the old select not matching the iOS/MD spec which is why this behavior broke when updating to the new form architecture.

    However, if you had access to .native-wrapper as a shadow part you could set width: 100% to customize that behavior and achieve the desired result. We have plans to expose this element as a shadow part in #27112, so I am going to merge the two threads.

    When this feature ships you will be able to do something like the following (naming subject to change):

    ion-select::part(wrapper) {
      width: 100%;
    }

    Here's what should look like:

    image

    I am going to close this in favor of #27112, but let me know if you have questions.

  2. lincolnthree commented on May 4, 2023

    @lincolnthree
    Author

    Perfect. That will absolutely solve this and I'm always a fan of extensibility vs. assumptions (I like your solution)! Thank you :)

  3. ionitron-bot commented on Jun 3, 2023

    @ionitron-bot

    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.

  4. locked and limited conversation to collaborators on Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions