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

Method _updateValueAndFireEvents

packages/main/src/TimePicker.ts:645–675  ·  view source on GitHub ↗
(value: string, normalizeValue: boolean, eventsNames: Array<"input" | "change" | "value-changed">)

Source from the content-addressed store, hash-verified

643 }
644
645 _updateValueAndFireEvents(value: string, normalizeValue: boolean, eventsNames: Array<"input" | "change" | "value-changed">) {
646 const isInputEvent = eventsNames.includes("input");
647 const valid = this.isValidValue(value);
648
649 let normalizedValue = value;
650 // Only normalize if valid - if invalid, keep raw value
651 if (value !== undefined && valid && normalizeValue && !isInputEvent) {
652 normalizedValue = this.normalizeValue(value); // transform valid values (in any format) to the correct format
653 }
654
655 // Store the previous value to check if it actually changed
656 const previousValue = this.value;
657
658 // During input events (live typing), only update tempValue, not the public value property
659 if (!isInputEvent) {
660 this.value = ""; // Do not remove! DurationPicker (an external component extending TimePicker) use case
661 this.value = normalizedValue;
662 }
663
664 // Always sync tempValue for the picker
665 this.tempValue = isInputEvent ? value : normalizedValue;
666 this._updateValueState(); // Change the value state to Error/None, but only if needed (must be called before early return)
667
668 if (previousValue === this.value) {
669 return;
670 }
671
672 eventsNames.forEach(eventName => {
673 this.fireDecoratorEvent(eventName, { value, valid });
674 });
675 }
676
677 _updateValueState() {
678 // During live typing, validate against displayFormat (what user types), otherwise validate against valueFormat (stored value)

Callers 8

submitPickersMethod · 0.95
submitInputsPopoverMethod · 0.95
_handleInputChangeMethod · 0.95
_modifyValueByMethod · 0.95
_submitClickMethod · 0.45
onSelectedDatesChangeMethod · 0.45
_modifyDateValueMethod · 0.45

Calls 3

isValidValueMethod · 0.95
normalizeValueMethod · 0.95
_updateValueStateMethod · 0.95

Tested by

no test coverage detected