@@ -16,7 +16,11 @@ import {
1616} from '../common/controllers/key-bindings.js' ;
1717import { defineComponents } from '../common/definitions/defineComponents.js' ;
1818import { equal } from '../common/util.js' ;
19- import { simulateClick , simulateKeyboard } from '../common/utils.spec.js' ;
19+ import {
20+ isFocused ,
21+ simulateClick ,
22+ simulateKeyboard ,
23+ } from '../common/utils.spec.js' ;
2024import IgcDateTimeInputComponent from '../date-time-input/date-time-input.js' ;
2125import IgcDatePickerComponent from './date-picker.js' ;
2226
@@ -963,6 +967,53 @@ describe('Date picker', () => {
963967 checkDatesEqual ( calendar . activeDate , expectedValue ) ;
964968 } ) ;
965969
970+ it ( 'issue 1884 - should emit igcChange event in dialog mode after clearing the value and losing focus' , async ( ) => {
971+ const eventSpy = spy ( picker , 'emitEvent' ) ;
972+ // const nativeInput = dateTimeInput.renderRoot.querySelector('input')!;
973+
974+ // Dropdown mode
975+
976+ picker . value = CalendarDay . today . native ;
977+ picker . focus ( ) ;
978+ picker . blur ( ) ;
979+ await elementUpdated ( picker ) ;
980+
981+ picker . focus ( ) ;
982+ expect ( isFocused ( dateTimeInput ) ) . to . be . true ;
983+
984+ // Simulate clicking the clear button
985+ picker . clear ( ) ;
986+
987+ picker . blur ( ) ;
988+ expect ( isFocused ( dateTimeInput ) ) . to . be . false ;
989+
990+ expect ( eventSpy ) . to . be . calledWith ( 'igcChange' , {
991+ detail : null ,
992+ } ) ;
993+
994+ eventSpy . resetHistory ( ) ;
995+
996+ // Dialog mode
997+ picker . mode = 'dialog' ;
998+ picker . value = CalendarDay . today . native ;
999+ picker . focus ( ) ;
1000+ picker . blur ( ) ;
1001+ await elementUpdated ( picker ) ;
1002+
1003+ picker . focus ( ) ;
1004+ expect ( isFocused ( dateTimeInput ) ) . to . be . true ;
1005+
1006+ // Simulate clicking the clear button
1007+ picker . clear ( ) ;
1008+
1009+ picker . blur ( ) ;
1010+ expect ( isFocused ( dateTimeInput ) ) . to . be . false ;
1011+
1012+ expect ( eventSpy ) . to . be . calledWith ( 'igcChange' , {
1013+ detail : null ,
1014+ } ) ;
1015+ } ) ;
1016+
9661017 describe ( 'Readonly state' , ( ) => {
9671018 describe ( 'Dropdown mode' , ( ) => {
9681019 beforeEach ( async ( ) => {
0 commit comments