-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(checkbox): display as block when justify or alignment properties are defined #29783
Changes from all commits
720ef8a
9887cf8
7365fb3
55a4843
dcb8a4a
a669fc2
86bf565
4097c38
75aa917
dd7f779
50b49a3
3742d54
c620298
4bce2f3
bcba3d5
cf38d15
fc3f1db
d284b02
6c9738e
6647ed2
a8120f3
94b4fc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ configs({ directions: ['ltr'] }).forEach(({ title, config, screenshot }) => { | |
font-size: 310%; | ||
} | ||
</style> | ||
<ion-checkbox justify="start" checked>Checked</ion-checkbox> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
<ion-checkbox checked>Checked</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,20 +2,50 @@ import { expect } from '@playwright/test'; | |
import { configs, test } from '@utils/test/playwright'; | ||
|
||
/** | ||
* By default ion-checkbox only takes up | ||
* as much space as it needs. Justification is | ||
* used for when the checkbox takes up the full | ||
* line (such as in an ion-item). As a result, | ||
* we set the width of the checkbox so we can | ||
* see the justification results. | ||
* By default ion-checkbox only takes up as much space | ||
* as it needs. Justification is used for when the | ||
* checkbox should take up the full line (such as in an | ||
* ion-item or when it has 100% width). | ||
*/ | ||
configs().forEach(({ title, screenshot, config }) => { | ||
test.describe(title('checkbox: label'), () => { | ||
test.describe('checkbox: default placement', () => { | ||
test('should render a space between justification with a full width checkbox', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox style="width: 100%"> | ||
Label | ||
</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
||
const checkbox = page.locator('ion-checkbox'); | ||
await expect(checkbox).toHaveScreenshot(screenshot(`checkbox-label-full-width`)); | ||
}); | ||
|
||
test('should truncate long labels with ellipses', async ({ page }) => { | ||
// Checkbox needs to be full width to truncate properly | ||
// because it is not inside of an `ion-app` in tests | ||
await page.setContent( | ||
` | ||
<ion-checkbox style="width: 100%"> | ||
Long Label Long Label Long Label Long Label Long Label Long Label | ||
</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
||
const checkbox = page.locator('ion-checkbox'); | ||
await expect(checkbox).toHaveScreenshot(screenshot(`checkbox-label-long-label`)); | ||
}); | ||
}); | ||
|
||
test.describe('checkbox: start placement', () => { | ||
test('should render a start justification with label in the start position', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="start" justify="start" style="width: 200px">Label</ion-checkbox> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An explicit width is no longer needed since using |
||
<ion-checkbox label-placement="start" justify="start">Label</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
@@ -27,7 +57,7 @@ configs().forEach(({ title, screenshot, config }) => { | |
test('should render an end justification with label in the start position', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="start" justify="end" style="width: 200px">Label</ion-checkbox> | ||
<ion-checkbox label-placement="start" justify="end">Label</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
@@ -39,7 +69,7 @@ configs().forEach(({ title, screenshot, config }) => { | |
test('should render a space between justification with label in the start position', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="start" justify="space-between" style="width: 200px">Label</ion-checkbox> | ||
<ion-checkbox label-placement="start" justify="space-between">Label</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
@@ -51,23 +81,23 @@ configs().forEach(({ title, screenshot, config }) => { | |
test('should truncate long labels with ellipses', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="start" justify="start" style="width: 200px"> | ||
<ion-checkbox label-placement="start" justify="start"> | ||
Long Label Long Label Long Label Long Label Long Label Long Label | ||
</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
||
const checkbox = page.locator('ion-checkbox'); | ||
await expect(checkbox).toHaveScreenshot(screenshot(`checkbox-long-label`)); | ||
await expect(checkbox).toHaveScreenshot(screenshot(`checkbox-label-start-justify-start-long-label`)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed this test to match the other prefixes in this describe block. |
||
}); | ||
}); | ||
|
||
test.describe('checkbox: end placement', () => { | ||
test('should render a start justification with label in the end position', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="end" justify="start" style="width: 200px">Label</ion-checkbox> | ||
<ion-checkbox label-placement="end" justify="start">Label</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
@@ -79,7 +109,7 @@ configs().forEach(({ title, screenshot, config }) => { | |
test('should render an end justification with label in the end position', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="end" justify="end" style="width: 200px">Label</ion-checkbox> | ||
<ion-checkbox label-placement="end" justify="end">Label</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
@@ -91,7 +121,7 @@ configs().forEach(({ title, screenshot, config }) => { | |
test('should render a space between justification with label in the end position', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="end" justify="space-between" style="width: 200px">Label</ion-checkbox> | ||
<ion-checkbox label-placement="end" justify="space-between">Label</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
@@ -105,7 +135,7 @@ configs().forEach(({ title, screenshot, config }) => { | |
test('should render a start justification with label in the fixed position', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="fixed" justify="start" style="width: 200px">This is a long label</ion-checkbox> | ||
<ion-checkbox label-placement="fixed" justify="start">This is a long label</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
@@ -117,7 +147,7 @@ configs().forEach(({ title, screenshot, config }) => { | |
test('should render an end justification with label in the fixed position', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="fixed" justify="end" style="width: 200px">This is a long label</ion-checkbox> | ||
<ion-checkbox label-placement="fixed" justify="end">This is a long label</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
@@ -129,7 +159,7 @@ configs().forEach(({ title, screenshot, config }) => { | |
test('should render a space between justification with label in the fixed position', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="fixed" justify="space-between" style="width: 200px">This is a long label</ion-checkbox> | ||
<ion-checkbox label-placement="fixed" justify="space-between">This is a long label</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
@@ -143,7 +173,7 @@ configs().forEach(({ title, screenshot, config }) => { | |
test('should align the label to the start of the container in the stacked position', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="stacked" alignment="start" style="width: 200px">This is a long label</ion-checkbox> | ||
<ion-checkbox label-placement="stacked" alignment="start">This is a long label</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
@@ -155,7 +185,7 @@ configs().forEach(({ title, screenshot, config }) => { | |
test('should align the label to the center of the container in the stacked position', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="stacked" alignment="center" style="width: 200px">This is a long label</ion-checkbox> | ||
<ion-checkbox label-placement="stacked" alignment="center">This is a long label</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
@@ -172,7 +202,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config, screen | |
test('long label should truncate', async ({ page }) => { | ||
await page.setContent( | ||
` | ||
<ion-checkbox label-placement="stacked" alignment="start" style="width: 200px">Enable Notifications Enable Notifications Enable Notifications Enable Notifications Enable Notifications Enable Notifications Enable Notifications</ion-checkbox> | ||
<ion-checkbox label-placement="stacked" alignment="start">Enable Notifications Enable Notifications Enable Notifications Enable Notifications Enable Notifications Enable Notifications Enable Notifications</ion-checkbox> | ||
`, | ||
config | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,10 +35,6 @@ | |
padding: 0; | ||
} | ||
} | ||
|
||
ion-checkbox { | ||
width: 100%; | ||
} | ||
</style> | ||
</head> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required so that the user can still do the following, with a space between the label and checkbox: