File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed
core/src/components/datetime Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -424,10 +424,10 @@ export class Datetime implements ComponentInterface {
424
424
* the date that is currently selected, otherwise
425
425
* there can be 1 hr difference when dealing w/ DST
426
426
*/
427
- const date = new Date ( convertDataToISO ( this . workingParts ) ) ;
428
- this . workingParts . tzOffset = date . getTimezoneOffset ( ) * - 1 ;
427
+ const date = new Date ( convertDataToISO ( this . activeParts ) ) ;
428
+ this . activeParts . tzOffset = date . getTimezoneOffset ( ) * - 1 ;
429
429
430
- this . value = convertDataToISO ( this . workingParts ) ;
430
+ this . value = convertDataToISO ( this . activeParts ) ;
431
431
432
432
if ( closeOverlay ) {
433
433
this . closeParentOverlay ( ) ;
Original file line number Diff line number Diff line change @@ -110,3 +110,41 @@ test('datetime:rtl: basic', async () => {
110
110
const compare = await page . compareScreenshot ( ) ;
111
111
expect ( compare ) . toMatchScreenshot ( ) ;
112
112
} ) ;
113
+
114
+
115
+ describe ( 'datetime: confirm date' , ( ) => {
116
+
117
+ test ( 'should set the date value based on the selected date' , async ( ) => {
118
+
119
+ const page = await newE2EPage ( {
120
+ html : `
121
+ <button>Bind datetimeMonthDidChange event</button>
122
+ <ion-datetime value="2021-12-25T12:40:00.000Z"></ion-datetime>
123
+ <script type="module">
124
+ import { InitMonthDidChangeEvent } from '/src/components/datetime/test/utils/month-did-change-event.js';
125
+ document.querySelector('button').addEventListener('click', function() {
126
+ InitMonthDidChangeEvent();
127
+ });
128
+ </script>
129
+ `
130
+ } ) ;
131
+
132
+ const eventButton = await page . find ( 'button' ) ;
133
+ await eventButton . click ( ) ;
134
+
135
+ const buttons = await page . findAll ( 'ion-datetime >>> .calendar-next-prev ion-button' ) ;
136
+
137
+ await buttons [ 1 ] . click ( ) ;
138
+
139
+ await page . waitForEvent ( 'datetimeMonthDidChange' ) ;
140
+
141
+ await page . $eval ( 'ion-datetime' , async ( el : any ) => {
142
+ await el . confirm ( ) ;
143
+ } ) ;
144
+
145
+ const value = await ( await page . find ( 'ion-datetime' ) ) . getProperty ( 'value' ) ;
146
+
147
+ expect ( value ) . toMatch ( '2021-12-25T12:40:00' ) ;
148
+ } ) ;
149
+
150
+ } ) ;
You can’t perform that action at this time.
0 commit comments