web-components icon indicating copy to clipboard operation
web-components copied to clipboard

fix: prevent possible errors in custom-field checkValidity

Open web-padawan opened this issue 1 year ago • 1 comments

Description

Fixes https://github.com/vaadin/flow-components/issues/6739

Updated checkValidity() method to check that this.inputs and this.value are defined before accessing them.

Type of change

  • Bugfix

web-padawan avatar Oct 23 '24 10:10 web-padawan

Hi @web-padawan and @web-padawan, when i performed cherry-pick to this commit to 24.4, i have encountered the following issue. Can you take a look and pick it manually? Error Message: Error: Command failed: git cherry-pick 82bfd11f8330642d77a33c41d1554a8dd973dc6c error: could not apply 82bfd11f83... fix: prevent possible errors when inputs property is not set (#8012) hint: After resolving the conflicts, mark them with hint: "git add/rm ", then run hint: "git cherry-pick --continue". hint: You can instead skip this commit with "git cherry-pick --skip". hint: To abort and get back to the state before "git cherry-pick", hint: run "git cherry-pick --abort".

vaadin-bot avatar Oct 24 '24 08:10 vaadin-bot

@web-padawan Just seen that you added target 24.4 but I never had this problems in 24.4. So maybe backport is not needed as there is all ok?

rappenze avatar Oct 24 '24 08:10 rappenze

We do have problems with the original change using the latest v24.4.17 platform (v24.4.12 Vaadin Flow) version. In some cases the inputs property is still undefined in the ready phase:

generated-flow-imports-CjbTJID0.js:7519 Uncaught TypeError: Cannot read properties of undefined (reading 'filter')
    at CustomField.checkValidity (generated-flow-impor…CjbTJID0.js:7519:39)
    at CustomField.validate (indexhtml-GaOLT410.js:20753:28)
    at CustomField._requiredChanged (generated-flow-impor…CjbTJID0.js:7535:12)
    at Object.runMethodEffect [as fn] (indexhtml-GaOLT410.js:9666:39)
    at runEffects (indexhtml-GaOLT410.js:9210:16)
    at CustomField._propertiesChanged (indexhtml-GaOLT410.js:10301:7)
    at Dx.s2._propertiesChanged (FlowClient-CfFCB582.js:9090:12)
    at CustomField._flushProperties (indexhtml-GaOLT410.js:8203:16)
    at CustomField.ready (indexhtml-GaOLT410.js:10269:12)
    at CustomField.ready (indexhtml-GaOLT410.js:12080:13)
    at CustomField.ready (indexhtml-GaOLT410.js:15164:13)
    at CustomField.ready (indexhtml-GaOLT410.js:15443:13)
    at CustomField.ready (indexhtml-GaOLT410.js:20709:13)
    at CustomField.ready (indexhtml-GaOLT410.js:20882:11)
    at CustomField.ready (generated-flow-impor…CjbTJID0.js:7465:11)
    at Dx.s2.ready (FlowClient-CfFCB582.js:9095:12)

@web-padawan could you backport this fix to the 24.4 branch as well? 🙏🙇‍♂️

lmorocz avatar Nov 25 '24 13:11 lmorocz

Sorry about not answering earlier, here's a PR with the cherry-pick to 24.4: https://github.com/vaadin/web-components/pull/8368

web-padawan avatar Dec 19 '24 09:12 web-padawan