MCPcopy Create free account
hub / github.com/UI5/webcomponents / _updateValueAndFireEvents

Method _updateValueAndFireEvents

packages/main/src/DatePicker.ts:582–615  ·  view source on GitHub ↗
(value: string, normalizeValue: boolean, events: Array<"change" | "value-changed" | "input">, updateValue: boolean = true)

Source from the content-addressed store, hash-verified

580 }
581
582 _updateValueAndFireEvents(value: string, normalizeValue: boolean, events: Array<"change" | "value-changed" | "input">, updateValue: boolean = true) {
583 const valid = this._checkValueValidity(value);
584 this.isLiveUpdate = !updateValue;
585 if ((valid && normalizeValue) || !this.isLiveUpdate) { // in case that value is not valid we format it in change event
586 value = this.getDisplayValueFromValue(value);
587 value = this.normalizeDisplayValue(value); // transform valid values (in any format) to the correct format
588 }
589
590 let executeEvent = true;
591 this.liveValue = value;
592 const previousValue = this.value;
593
594 if (updateValue) {
595 this._dateTimeInput.value = value;
596 this.value = this.getValueFromDisplayValue(value);
597 this._updateValueState();
598 }
599
600 events.forEach(e => {
601 if (!this.fireDecoratorEvent(e, { value: this.value, valid })) {
602 executeEvent = false;
603 }
604 });
605
606 if (!executeEvent && updateValue) {
607 if (this.value !== previousValue && this.value !== this._dateTimeInput.value) {
608 return; // If the value was changed in the change event, do not revert it
609 }
610
611 this._dateTimeInput.value = previousValue;
612
613 this.value = previousValue;
614 }
615 }
616
617 _updateValueState() {
618 const valid = this._checkValueValidity(this.value);

Callers 4

_modifyDateValueMethod · 0.95
_onInputChangeMethod · 0.95
_onInputInputMethod · 0.95
onSelectedDatesChangeMethod · 0.95

Calls 5

_checkValueValidityMethod · 0.95
normalizeDisplayValueMethod · 0.95
_updateValueStateMethod · 0.95

Tested by

no test coverage detected