Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(datetime): prefer wheel sets working value on confirmation (#28520)
Issue number: resolves #25839 --------- <!-- 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. --> Confirming the working day when a datetime using a wheel picker without an initial value will result in a value of `undefined` instead of the displayed working day the user sees. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - `preferWheel` uses the working value on confirmation ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Dev-build: `7.5.7-dev.11701896424.13d40ac9` Co-authored-by: liamdebeasi <liamdebeasi@users.noreply.github.com>
- Loading branch information
1 parent
37290df
commit e886e3f
Showing
4 changed files
with
327 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 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
31 changes: 31 additions & 0 deletions
31
core/src/components/datetime/test/prefer-wheel/datetime.spec.ts
This file contains 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,31 @@ | ||
import { newSpecPage } from '@stencil/core/testing'; | ||
|
||
import { Datetime } from '../../datetime'; | ||
|
||
describe('datetime: preferWheel', () => { | ||
beforeEach(() => { | ||
const mockIntersectionObserver = jest.fn(); | ||
mockIntersectionObserver.mockReturnValue({ | ||
observe: () => null, | ||
unobserve: () => null, | ||
disconnect: () => null, | ||
}); | ||
global.IntersectionObserver = mockIntersectionObserver; | ||
}); | ||
|
||
it('should select the working day when clicking the confirm button', async () => { | ||
const page = await newSpecPage({ | ||
components: [Datetime], | ||
html: '<ion-datetime prefer-wheel="true" max="2021" show-default-buttons="true"></ion-datetime>', | ||
}); | ||
|
||
const datetime = page.body.querySelector<HTMLIonDatetimeElement>('ion-datetime')!; | ||
const confirmButton = datetime.shadowRoot!.querySelector<HTMLIonButtonElement>('#confirm-button')!; | ||
|
||
confirmButton.click(); | ||
|
||
await page.waitForChanges(); | ||
|
||
expect(datetime.value).toBe('2021-12-31T23:59:00'); | ||
}); | ||
}); |
Oops, something went wrong.