-
Notifications
You must be signed in to change notification settings - Fork 13.5k
feat(select): add label slot #27468
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
Merged
Merged
feat(select): add label slot #27468
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8bcfebb
feat(select): add label slot
liamdebeasi 186d759
fix(select): label slot content is passed as default title for alert
liamdebeasi 8acbec5
lint
liamdebeasi 27d1cd1
fix(select): slotted content can truncate
liamdebeasi 3bf0b70
test(select): add tests to verify prop/slot behavior
liamdebeasi 45ea21d
test(select): verify alert header slot behavior
liamdebeasi 1885823
fix(select): label is hidden if no content passed
liamdebeasi b1bb1f8
clarify getters
liamdebeasi 3974407
test(select): verify header works with prop and slot
liamdebeasi 99006c4
remove only
liamdebeasi 02a430a
fix(select): pass correct value to aria-label
liamdebeasi 3d1eda8
test(select): add screenshot for slot truncate
liamdebeasi d297267
chore(): add updated snapshots
Ionitron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+9.07 KB
...lect.e2e.ts-snapshots/select-label-slot-truncate-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.93 KB
...ect.e2e.ts-snapshots/select-label-slot-truncate-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.77 KB
...lect.e2e.ts-snapshots/select-label-slot-truncate-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { newSpecPage } from '@stencil/core/testing'; | ||
|
||
import { Select } from '../select'; | ||
|
||
describe('ion-select', () => { | ||
it('should render label prop if only prop provided', async () => { | ||
const page = await newSpecPage({ | ||
components: [Select], | ||
html: ` | ||
<ion-select label="Label Prop Text"></ion-select> | ||
`, | ||
}); | ||
|
||
const select = page.body.querySelector('ion-select'); | ||
|
||
const propEl = select.shadowRoot.querySelector('.label-text'); | ||
const slotEl = select.shadowRoot.querySelector('slot[name="label"]'); | ||
|
||
expect(propEl).not.toBe(null); | ||
expect(slotEl).toBe(null); | ||
}); | ||
it('should render label slot if only slot provided', async () => { | ||
const page = await newSpecPage({ | ||
components: [Select], | ||
html: ` | ||
<ion-select><div slot="label">Label Prop Slot</div></ion-select> | ||
`, | ||
}); | ||
|
||
const select = page.body.querySelector('ion-select'); | ||
|
||
const propEl = select.shadowRoot.querySelector('.label-text'); | ||
const slotEl = select.shadowRoot.querySelector('slot[name="label"]'); | ||
|
||
expect(propEl).toBe(null); | ||
expect(slotEl).not.toBe(null); | ||
}); | ||
it('should render label prop if both prop and slot provided', async () => { | ||
const page = await newSpecPage({ | ||
components: [Select], | ||
html: ` | ||
<ion-select label="Label Prop Text"><div slot="label">Label Prop Slot</div></ion-select> | ||
`, | ||
}); | ||
|
||
const select = page.body.querySelector('ion-select'); | ||
|
||
const propEl = select.shadowRoot.querySelector('.label-text'); | ||
const slotEl = select.shadowRoot.querySelector('slot[name="label"]'); | ||
|
||
expect(propEl).not.toBe(null); | ||
expect(slotEl).toBe(null); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Passing this as-is to the alert header gives odd results when using a more complicated label structure. For example, opening this:
Leads to this:
While I can't think of a good way to have Ionic solve this automatically, I noticed you can overwrite it manually using
interfaceOptions
, and that still works:Maybe we'll just want to document this pattern and leave it as-is?
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.
Yep, I can make sure this is documented.