Skip to content

Commit 6cb24cb

Browse files
authored
fix(date-time-input): ensure 'igcChange' is emitted in case an incomplete mask value has been filled (#1696)
1 parent 38f25e4 commit 6cb24cb

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [Unreleased]
8+
### Fixed
9+
- #### DateTime Input
10+
- Ensure `igcChange` is emitted in case an incomplete mask value has been filled [#1695](https://github.com/IgniteUI/igniteui-webcomponents/issues/1695)
11+
712
## [6.0.0] - 2025-04-29
813
### Changed
914
- Minimum Node version required is now >= 20.

src/components/date-time-input/date-time-input.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,24 @@ describe('Date Time Input component', () => {
175175
expect(input.value).to.equal('22-07-2024');
176176
});
177177

178+
it('should emit igcChange on blur after an incomplete mask has been parsed - issue #1695', async () => {
179+
const eventSpy = spy(el, 'emitEvent');
180+
el.focus();
181+
await elementUpdated(el);
182+
183+
simulateInput(input, {
184+
value: '0',
185+
inputType: 'insertText',
186+
});
187+
await elementUpdated(el);
188+
189+
el.blur();
190+
await elementUpdated(el);
191+
192+
expect(eventSpy).calledWith('igcChange');
193+
expect(input.value).to.deep.equal('01/01/2000');
194+
});
195+
178196
it('should correctly switch between different pre-defined date formats', async () => {
179197
const targetDate = new Date(2020, 2, 3, 0, 0, 0, 0);
180198

src/components/date-time-input/date-time-input.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ export default class IgcDateTimeInputComponent extends EventEmitterMixin<
609609

610610
protected handleBlur() {
611611
const isEmptyMask = this.maskedValue === this.emptyMask;
612-
const isSameValue = this._oldValue === this.value;
613612

614613
this.focused = false;
615614

@@ -626,6 +625,8 @@ export default class IgcDateTimeInputComponent extends EventEmitterMixin<
626625
this.updateMask();
627626
}
628627

628+
const isSameValue = this._oldValue === this.value;
629+
629630
if (!(this.readOnly || isSameValue)) {
630631
this.emitEvent('igcChange', { detail: this.value });
631632
}

0 commit comments

Comments
 (0)