Skip to content

Commit acc1042

Browse files
fix(input, textarea, select): account for multiple start/end slot elements (#29172)
Issue number: Internal --------- <!-- 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. --> We add margin on content in the start/end slots so they do not run up against either the visible text label of the text in the input. However, we did not account for when multiple elements are placed into the same slot. As a result, this margin is added more times than it needs to be. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Updated the selector so the margin is only applied to either the last or first element in the slot. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Test Steps: 1. Check out `feature-8.0` 2. Add multiple `ion-button` elements into either the start or end slot on an input (you can reuse the template in `src/components/input/test/slots` 3. Observe that margin is added to every `ion-button`. --------- Co-authored-by: ionitron <[email protected]>
1 parent 761e1b4 commit acc1042

File tree

78 files changed

+30
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+30
-6
lines changed

core/src/components/input/input.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,12 +596,12 @@
596596
// Start/End Slots
597597
// ----------------------------------------------------------------
598598

599-
::slotted([slot="start"]) {
599+
::slotted([slot="start"]:last-of-type) {
600600
margin-inline-end: $form-control-label-margin;
601601
margin-inline-start: 0;
602602
}
603603

604-
::slotted([slot="end"]) {
604+
::slotted([slot="end"]:first-of-type) {
605605
margin-inline-start: $form-control-label-margin;
606606
margin-inline-end: 0;
607607
}

core/src/components/input/test/slot/input.e2e.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ configs().forEach(({ title, screenshot, config }) => {
88
`
99
<ion-input label-placement="start" fill="solid" value="100" label="Weight" clear-input="true">
1010
<ion-icon slot="start" name="barbell" aria-hidden="true"></ion-icon>
11+
<ion-icon slot="start" name="heart" aria-hidden="true"></ion-icon>
1112
<ion-button slot="end" aria-label="Show/hide password">
1213
<ion-icon slot="icon-only" name="lock-closed" aria-hidden="true"></ion-icon>
1314
</ion-button>
15+
<ion-button slot="end">
16+
<ion-icon slot="icon-only" name="trash" aria-hidden="true"></ion-icon>
17+
</ion-button>
1418
</ion-input>
1519
`,
1620
config
@@ -25,9 +29,13 @@ configs().forEach(({ title, screenshot, config }) => {
2529
`
2630
<ion-input label-placement="floating" fill="solid" value="100" label="Weight" clear-input="true">
2731
<ion-icon slot="start" name="barbell" aria-hidden="true"></ion-icon>
32+
<ion-icon slot="start" name="heart" aria-hidden="true"></ion-icon>
2833
<ion-button slot="end" aria-label="Show/hide password">
2934
<ion-icon slot="icon-only" name="lock-closed" aria-hidden="true"></ion-icon>
3035
</ion-button>
36+
<ion-button slot="end">
37+
<ion-icon slot="icon-only" name="trash" aria-hidden="true"></ion-icon>
38+
</ion-button>
3139
</ion-input>
3240
`,
3341
config
1.28 KB
1.41 KB
1.75 KB
1.28 KB
1.38 KB
1.72 KB
1.25 KB
1.64 KB

0 commit comments

Comments
 (0)