Skip to content

Commit

Permalink
fix(input, textarea, select): account for multiple start/end slot ele…
Browse files Browse the repository at this point in the history
…ments (#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]>
  • Loading branch information
liamdebeasi and Ionitron authored Mar 19, 2024
1 parent 761e1b4 commit acc1042
Show file tree
Hide file tree
Showing 78 changed files with 30 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/src/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,12 @@
// Start/End Slots
// ----------------------------------------------------------------

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

::slotted([slot="end"]) {
::slotted([slot="end"]:first-of-type) {
margin-inline-start: $form-control-label-margin;
margin-inline-end: 0;
}
8 changes: 8 additions & 0 deletions core/src/components/input/test/slot/input.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ configs().forEach(({ title, screenshot, config }) => {
`
<ion-input label-placement="start" fill="solid" value="100" label="Weight" clear-input="true">
<ion-icon slot="start" name="barbell" aria-hidden="true"></ion-icon>
<ion-icon slot="start" name="heart" aria-hidden="true"></ion-icon>
<ion-button slot="end" aria-label="Show/hide password">
<ion-icon slot="icon-only" name="lock-closed" aria-hidden="true"></ion-icon>
</ion-button>
<ion-button slot="end">
<ion-icon slot="icon-only" name="trash" aria-hidden="true"></ion-icon>
</ion-button>
</ion-input>
`,
config
Expand All @@ -25,9 +29,13 @@ configs().forEach(({ title, screenshot, config }) => {
`
<ion-input label-placement="floating" fill="solid" value="100" label="Weight" clear-input="true">
<ion-icon slot="start" name="barbell" aria-hidden="true"></ion-icon>
<ion-icon slot="start" name="heart" aria-hidden="true"></ion-icon>
<ion-button slot="end" aria-label="Show/hide password">
<ion-icon slot="icon-only" name="lock-closed" aria-hidden="true"></ion-icon>
</ion-button>
<ion-button slot="end">
<ion-icon slot="icon-only" name="trash" aria-hidden="true"></ion-icon>
</ion-button>
</ion-input>
`,
config
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions core/src/components/select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -556,12 +556,12 @@ button {
flex-shrink: 0;
}

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

::slotted([slot="end"]) {
::slotted([slot="end"]:first-of-type) {
margin-inline-start: $form-control-label-margin;
margin-inline-end: 0;
}
8 changes: 8 additions & 0 deletions core/src/components/select/test/slot/select.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ configs().forEach(({ title, screenshot, config }) => {
`
<ion-select label-placement="start" fill="solid" placeholder="Select weight" label="Weight">
<ion-icon slot="start" name="barbell" aria-hidden="true"></ion-icon>
<ion-icon slot="start" name="heart" aria-hidden="true"></ion-icon>
<ion-button slot="end" aria-label="Show/hide password">
<ion-icon slot="icon-only" name="lock-closed" aria-hidden="true"></ion-icon>
</ion-button>
<ion-button slot="end">
<ion-icon slot="icon-only" name="trash" aria-hidden="true"></ion-icon>
</ion-button>
</ion-select>
`,
config
Expand All @@ -25,9 +29,13 @@ configs().forEach(({ title, screenshot, config }) => {
`
<ion-select label-placement="floating" fill="solid" placeholder="Select weight" label="Weight">
<ion-icon slot="start" name="barbell" aria-hidden="true"></ion-icon>
<ion-icon slot="start" name="heart" aria-hidden="true"></ion-icon>
<ion-button slot="end" aria-label="Show/hide password">
<ion-icon slot="icon-only" name="lock-closed" aria-hidden="true"></ion-icon>
</ion-button>
<ion-button slot="end">
<ion-icon slot="icon-only" name="trash" aria-hidden="true"></ion-icon>
</ion-button>
</ion-select>
`,
config
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions core/src/components/textarea/test/slot/textarea.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ configs().forEach(({ title, screenshot, config }) => {
`
<ion-textarea label-placement="start" fill="solid" value="100" label="Weight">
<ion-icon slot="start" name="barbell" aria-hidden="true"></ion-icon>
<ion-icon slot="start" name="heart" aria-hidden="true"></ion-icon>
<ion-button slot="end" aria-label="Show/hide password">
<ion-icon slot="icon-only" name="lock-closed" aria-hidden="true"></ion-icon>
</ion-button>
<ion-button slot="end">
<ion-icon slot="icon-only" name="trash" aria-hidden="true"></ion-icon>
</ion-button>
</ion-textarea>
`,
config
Expand All @@ -25,9 +29,13 @@ configs().forEach(({ title, screenshot, config }) => {
`
<ion-textarea label-placement="floating" fill="solid" value="100" label="Weight">
<ion-icon slot="start" name="barbell" aria-hidden="true"></ion-icon>
<ion-icon slot="start" name="heart" aria-hidden="true"></ion-icon>
<ion-button slot="end" aria-label="Show/hide password">
<ion-icon slot="icon-only" name="lock-closed" aria-hidden="true"></ion-icon>
</ion-button>
<ion-button slot="end">
<ion-icon slot="icon-only" name="trash" aria-hidden="true"></ion-icon>
</ion-button>
</ion-textarea>
`,
config
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/textarea/textarea.scss
Original file line number Diff line number Diff line change
Expand Up @@ -684,12 +684,12 @@
margin-top: 0; // ensure slot content is vertically aligned with label
}

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

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

0 comments on commit acc1042

Please sign in to comment.