Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
sling:resourceType="forms-components-examples/components/form/datepicker"
enabled="{Boolean}true"
fieldType="date-input"
displayFormat="d MMMM, y"
displayPatternType="d MMMM, y"
name="dob"
readOnly="{Boolean}false"
textIsRich="[true,true]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@
if (this.widgetObject == null) {
this.widgetObject = new DatePickerWidget(this, this.getWidget(), model);
}
if (this.widgetObject.getValue() !== '') {
this._model.value = this.widgetObject.getValue();
if (this.isActive()) {
this.widgetObject.setValue(model.value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we setting widget value in setting of model? Ideally this should be the job of updateValue not setModel
Earlier model value was being set via widget, you have al together removed that code..

Copy link
Collaborator Author

@rismehta rismehta Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Earlier model value was being set via widget, you have al together removed that code

It was redundant because the model value is already established upon initializing the datePickerWidget. If you observe the third argument, it contains the model.

In the setModel function, the model already possesses the correct value from af-core. Consequently, setting the value again within the model was redundant, as the value remained unchanged, and updateState was not invoked in this context.

Ideally this should be the job of updateValue not setModel

Ideally, we should utilize updateValue. However, during prefill/initialize, updateValue lacks initialization of the widgetObject, resulting in failure. Although I considered making this change of initializing widgetObject in updateValue like we do in number input but it would require significant refactoring, which isn't necessary at this juncture.

Copy link
Contributor

@sakshi-arora1 sakshi-arora1 Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you open a JIRA to correct this flow, to align with other views. And do link that JIRA to the original issue so it could be tracked.

} else {
this.widgetObject.setDisplayValue(model.value);
}
this.widgetObject.addEventListener('blur', (e) => {
this._model.value = this.widgetObject.getValue();

//setDisplayValue is required for cases where value remains same while focussing in and out.
this.widgetObject.setDisplayValue(this._model.value);

this.setInactive();
}, this.getWidget());
this.widgetObject.addEventListener('focus', (e) => {
Expand All @@ -104,7 +104,6 @@
this.setActive();
});
}

}

#noFormats() {
Expand Down
2 changes: 1 addition & 1 deletion ui.tests/test-module/specs/prefill/customprefill.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Custom Prefill Test', function () {
cy.previewForm(pagePath, {"params" : [`prefillId=${prefillId}`]});
// validating the prefilled data
cy.get(nameTextBox).should("have.value", "John Doe");
cy.get(dobDropdown).should("have.value", "1999-10-10");
cy.get(dobDropdown).should("have.value", "10 October, 1999");
cy.get(genderRadioButton).should("have.value", "0");
cy.get(jobDropdown).should("have.value", "1");
}
Expand Down