You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(ion-select): No longer possible to set margin: auto on ::part(icon) #27392
I have searched for existing issues that already report this problem, without success.
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):
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.
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.)
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:
I am going to close this in favor of #27112, but let me know if you have questions.
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.
Activity
liamdebeasi commentedon May 4, 2023
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: autostyles 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-wrapperas a shadow part you could setwidth: 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):
Here's what should look like:
I am going to close this in favor of #27112, but let me know if you have questions.
lincolnthree commentedon May 4, 2023
Perfect. That will absolutely solve this and I'm always a fan of extensibility vs. assumptions (I like your solution)! Thank you :)
ionitron-bot commentedon Jun 3, 2023
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.