Skip to content

UIOR-1569: Correct refresh of prefix and suffix fields - #1875

Merged
charismatic-claire merged 1 commit into
masterfrom
UIOR-1569-correct-refresh-of-prefix-and-suffix
Aug 6, 2026
Merged

UIOR-1569: Correct refresh of prefix and suffix fields#1875
charismatic-claire merged 1 commit into
masterfrom
UIOR-1569-correct-refresh-of-prefix-and-suffix

Conversation

@charismatic-claire

@charismatic-claire charismatic-claire commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Purpose

https://folio-org.atlassian.net/browse/UIOR-1569

This is a bugfix for the following problem: Prefix and suffix do not correctly refresh on selection in the create and edit of a Purchase Order.

Approach

How did we solve this? Well, FieldPrefix and FieldSuffix contained broken validation logic, s.t. we could run into cases where we need to validate fields that aren't present. To fix that, we put the condition shouldRevalidatePoNumber in place, taking care of that cases. That makes sure we only run the validation when poNumber was mounted and is actually present, s.t. it can really be used for validation.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

Jest Unit Test Results

    1 files  ±0    307 suites  ±0   6m 50s ⏱️ -1s
1 138 tests +4  1 130 ✅ +4  8 💤 ±0  0 ❌ ±0 
1 146 runs  +4  1 138 ✅ +4  8 💤 ±0  0 ❌ ±0 

Results for commit a7a39ae. ± Comparison against base commit 820d529.

This pull request removes 2 and adds 6 tests. Note that renamed tests count towards both.
FieldPrefix should render 'prefix' field ‑ FieldPrefix should render 'prefix' field
FieldSuffix should render 'suffix' field ‑ FieldSuffix should render 'suffix' field
FieldPrefix should not validate PO number when shouldValidate is false ‑ FieldPrefix should not validate PO number when shouldValidate is false
FieldPrefix should render the prefix field ‑ FieldPrefix should render the prefix field
FieldPrefix should validate PO number when shouldValidate is true ‑ FieldPrefix should validate PO number when shouldValidate is true
FieldSuffix should not validate PO number when shouldValidate is false ‑ FieldSuffix should not validate PO number when shouldValidate is false
FieldSuffix should render the suffix field ‑ FieldSuffix should render the suffix field
FieldSuffix should validate PO number when shouldValidate is true ‑ FieldSuffix should validate PO number when shouldValidate is true

♻️ This comment has been updated with latest results.

@charismatic-claire charismatic-claire changed the title UI or 1569 correct refresh of prefix and suffix UIOR-1569: Correct refresh of prefix and suffix fields Jul 22, 2026
@charismatic-claire
charismatic-claire force-pushed the UIOR-1569-correct-refresh-of-prefix-and-suffix branch from 65ef658 to 026f5f2 Compare July 22, 2026 11:39
Comment thread src/common/POFields/FieldPrefix.js Outdated
@elsenhans

Copy link
Copy Markdown
Contributor

Please add ticket to CHANGELOG.md

@charismatic-claire
charismatic-claire force-pushed the UIOR-1569-correct-refresh-of-prefix-and-suffix branch from 026f5f2 to 23cfc16 Compare July 22, 2026 12:01
Comment thread src/common/POFields/FieldPrefix.test.js Outdated
Comment thread src/common/POFields/FieldPrefix.test.js
Comment thread src/common/POFields/FieldPrefix.test.js Outdated
Comment thread src/common/POFields/FieldPrefix.test.js Outdated
Comment thread src/common/POFields/FieldSuffix.test.js Outdated
Comment thread src/common/POFields/FieldPrefix.test.js Outdated
Comment thread src/common/POFields/FieldSuffix.test.js Outdated
@charismatic-claire
charismatic-claire force-pushed the UIOR-1569-correct-refresh-of-prefix-and-suffix branch from 23cfc16 to a149e79 Compare July 22, 2026 13:57
@charismatic-claire

Copy link
Copy Markdown
Contributor Author

@elsenhans Do you like the changes?

@elsenhans

elsenhans commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@elsenhans Do you like the changes?

Looking good. Thanks for the additional test case.
Some small points:

  1. Seems like line 20 is unused:
    const React = jest.requireActual('react');
    Please remove it.

  2. Fix eslint errors in FieldPrefix.test.js and FieldSuffix.test.js

@NikitaSedyx NikitaSedyx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please address linter issues

additionally I didn't get how validation exclusion when po number is present solves your issue, I believe you just need to make component rerender and do not touch validation

@charismatic-claire

Copy link
Copy Markdown
Contributor Author

@elsenhans Thanks for finding this, I'll address the issue.
@NikitaSedyx I will address the linter issues. On your second question: I think the thrown exceptions due to the throwing validation (because it cannot grab the value to validate) IS THE CAUSE of the issue of the field not refreshing properly. See the video attached. Otherwise I wouldn't expect that an input field update requires a manual refresh. The reactive nature of, well... React, should take care of that. I think.

Screencast_20260723_123408.webm

@charismatic-claire
charismatic-claire force-pushed the UIOR-1569-correct-refresh-of-prefix-and-suffix branch from a149e79 to f8b8b82 Compare July 23, 2026 10:54
@charismatic-claire

Copy link
Copy Markdown
Contributor Author

@elsenhans I adressed your comments.

@NikitaSedyx I fixed all the linter issues including two unrelated ones. I added an extra commit for it to indicate the fix doesn't belong to the ticket itself.

);

useEffect(refreshList, [lineId]);
useEffect(refreshList, [lineId, refreshList]);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@NikitaSedyx out of scope linter fix in extra commit. If that's considered bad practice, we can remove it.

Comment thread src/components/PurchaseOrder/POForm.js Outdated
}));
}
}, []);
}, [initialValues.template, parentResources?.orderTemplates?.records]);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@NikitaSedyx out of scope linter fix in extra commit. If that's considered bad practice, we can remove it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would suggest to not fix issues not connected to your changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Alrighty

@NikitaSedyx

Copy link
Copy Markdown
Contributor

I think the thrown exceptions due to the throwing validation (because it cannot grab the value to validate) IS THE CAUSE of the issue of the field not refreshing properly. See the video attached. Otherwise I wouldn't expect that an input field update requires a manual refresh. The reactive nature of, well... React, should take care of that. I think.

hm, in some extent it makes sense, but I would like to play a bit - it's pretty old code so I do not remember all details

@charismatic-claire

Copy link
Copy Markdown
Contributor Author

@NikitaSedyx did you take a look and could reproduce the bug and verify the fix?

We add a 'shouldValidate' property to 'FieldPrefix' and 'FieldSuffix',
which is used to determine whether validating the input should be done
or not. This way we do not validate if the 'poNumber' is not editable
and hence accessible to the validators.
@charismatic-claire
charismatic-claire force-pushed the UIOR-1569-correct-refresh-of-prefix-and-suffix branch 2 times, most recently from 459996c to a7a39ae Compare August 6, 2026 08:20
@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

@elsenhans elsenhans left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LG

@charismatic-claire
charismatic-claire merged commit e977e38 into master Aug 6, 2026
16 checks passed
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.

3 participants