fix(alert): remove border-right on ios stacked buttons (#28821)

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. -->

When iOS alert has 3 or more buttons, those are rendered vertically. All
but the last button will have a right border. There shouldn't be a right
border when the buttons are stacked.

![Group
2(1)](https://github.com/ionic-team/ionic-framework/assets/13530427/0bc2a46e-554c-459a-85cb-990f4b4918ed)


## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Vertical buttons don't have a right border.
- Separated the test in order to also test dark theme.

![Screenshot 2024-01-12 at 1 00
54 PM](https://github.com/ionic-team/ionic-framework/assets/13530427/5ec9d00f-2893-4045-9b63-2817549c80b1)
![Screenshot 2024-01-12 at 12 58
22 PM](https://github.com/ionic-team/ionic-framework/assets/13530427/5b64a959-b8e1-4b6a-bd9c-92d1d381a65a)


## 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. -->

N/A

---------

Co-authored-by: ionitron <hi@ionicframework.com>
This commit is contained in:
Maria Hutt
2024-01-17 09:12:07 -08:00
committed by GitHub
parent aed7a03532
commit ad65824722
26 changed files with 51 additions and 5 deletions

View File

@ -265,6 +265,22 @@
flex-wrap: $alert-ios-button-group-flex-wrap;
}
/**
* The right border should only be applied to the first button
* when the group has 2 or less buttons (horizontal).
* Otherwise, the right border should not be applied
* when the group has 3 or more buttons (vertical).
*/
.alert-button-group-vertical .alert-button {
border-right: none;
&:last-child {
@include rtl() {
border-right: none;
}
}
}
.alert-button {
/**
* This padding ensures that alerts

View File

@ -73,11 +73,6 @@ configs().forEach(({ config, screenshot, title }) => {
await alertFixture.screenshot('longMessage');
});
test('more than two buttons', async () => {
await alertFixture.open('#multipleButtons');
await alertFixture.screenshot('multipleButtons');
});
test('no message', async () => {
await alertFixture.open('#noMessage');
await alertFixture.screenshot('noMessage');
@ -105,6 +100,41 @@ configs().forEach(({ config, screenshot, title }) => {
});
});
configs({ themes: ['light', 'dark'] }).forEach(({ config, screenshot, title }) => {
test.describe(title('should not have visual regressions'), () => {
test('more than two buttons', async ({ page }) => {
await page.setContent(
`
<ion-alert
header="Alert"
sub-header="Subtitle"
message="This is an alert message."
is-open="true"
></ion-alert>
<script>
const alert = document.querySelector('ion-alert');
alert.buttons = [
'Open Modal',
{
text: 'Delete',
id: 'delete-button',
role: 'destructive',
},
'Cancel'
];
</script>
`,
config
);
const alert = page.locator('ion-alert');
await expect(alert).toHaveScreenshot(screenshot(`alert-multipleButtons`));
});
});
});
class AlertFixture {
readonly page: E2EPage;
readonly screenshotFn?: (file: string) => string;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 13 KiB