-
Notifications
You must be signed in to change notification settings - Fork 13.4k
feat(searchbar): autocapitalize, dir, lang, maxlength, and minlength are inherited to native input #29098
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(searchbar): autocapitalize, dir, lang, maxlength, and minlength are inherited to native input #29098
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d76260a
add initial props
liamdebeasi 6bd8d21
test(searchbar): add failing test
liamdebeasi 9bfcb00
feat(searchbar): inherit common attributes
liamdebeasi 6913c26
typo
liamdebeasi 5a455bf
test(searchbar): add tests for properties too
liamdebeasi 14cd8b1
default to undefined
liamdebeasi 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,37 @@ import { newSpecPage } from '@stencil/core/testing'; | |
import { Searchbar } from '../searchbar'; | ||
|
||
describe('searchbar: rendering', () => { | ||
it('should inherit attributes', async () => { | ||
it('should inherit properties on load', async () => { | ||
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. I did not test updating the properties because that would be testing Stencil behavior. I am, however, testing updating attributes to verify that I configured the attribute watchers correctly. |
||
const page = await newSpecPage({ | ||
components: [Searchbar], | ||
html: '<ion-searchbar name="search"></ion-searchbar>', | ||
html: '<ion-searchbar autocapitalize="off" maxlength="4" minlength="2" name="search"></ion-searchbar>', | ||
}); | ||
|
||
const nativeEl = page.body.querySelector('ion-searchbar input')!; | ||
expect(nativeEl.getAttribute('name')).toBe('search'); | ||
expect(nativeEl.getAttribute('maxlength')).toBe('4'); | ||
expect(nativeEl.getAttribute('minlength')).toBe('2'); | ||
expect(nativeEl.getAttribute('autocapitalize')).toBe('off'); | ||
}); | ||
|
||
it('should inherit watched attributes', async () => { | ||
const page = await newSpecPage({ | ||
components: [Searchbar], | ||
html: '<ion-searchbar dir="ltr" lang="en-US"></ion-searchbar>', | ||
}); | ||
|
||
const searchbarEl = page.body.querySelector('ion-searchbar')!; | ||
const nativeEl = searchbarEl.querySelector('input')!; | ||
|
||
expect(nativeEl.getAttribute('lang')).toBe('en-US'); | ||
expect(nativeEl.getAttribute('dir')).toBe('ltr'); | ||
|
||
searchbarEl.setAttribute('lang', 'es-ES'); | ||
searchbarEl.setAttribute('dir', 'rtl'); | ||
|
||
await page.waitForChanges(); | ||
|
||
expect(nativeEl.getAttribute('lang')).toBe('es-ES'); | ||
expect(nativeEl.getAttribute('dir')).toBe('rtl'); | ||
}); | ||
}); |
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
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.
I can make a tech debt ticket for this, but my plan was to make the change once this is merged since Ionic 8 is in beta now (and we can still make breaking changes).