Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(molgenis-components): null-check for expressions when a field is emptied after being filled #4189

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

svandenhoek
Copy link
Contributor

What are the main changes you did:
Fixed a bug where empty value validation was bugged. Once a field is filled, it cannot be put back into its original (value is null) state. Similar to #3933.

Example:

Schermopname.2024-09-05.om.18.54.56.mov

To be more specific, if having a table with 2 columns (c1 & c2), where c2 can only be filled if c1 is empty, different code would give different errors:

c1 == null -> only worked as long as c1 is empty, if filled and emptied again the error message would remain
c1.length === 0 -> only worked AFTER value was set and then emptied, but when trying to save give the error Update into table 'test' failed.: Transaction failed: script failed: TypeError: Cannot read property 'length' of null
c1 == null || c1.length === 0 -> works but ugly

This PR should address the issue above and make <colName> == null always usable. It fixes InputString, InputText, InputEmail, InputHyperlink & InputPassword.

Only InputString was tested manually with validation string in an actual database table. Other ones have e2e tests to see if value is set to null if empty input field.

how to test:

todo:

  • updated docs in case of new feature
  • added/updated tests
  • added/updated testplan to include a test for this fix, including ref to bug using # notation

@svandenhoek svandenhoek changed the title fix(molgenis-components): fixed a bug causing null-check for form expressions to fail fix(molgenis-components): fixed a bug causing null-check for expressions to fail Sep 5, 2024
@svandenhoek svandenhoek changed the title fix(molgenis-components): fixed a bug causing null-check for expressions to fail fix(molgenis-components): null-check for expressions when a field is emptied after being filled Sep 5, 2024
Copy link

sonarcloud bot commented Sep 5, 2024

@@ -52,6 +52,10 @@ let props = defineProps({

const emit = defineEmits(["update:modelValue"]);

function updateModelValue(value) {
emit("update:modelValue", value == "" ? null : value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use === instead of ==

Comment on lines +47 to +50
function updateModelValue(value) {
emit("update:modelValue", value == "" ? null : value);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Please put functions at the end of the script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants