Skip to content

Commit

Permalink
chore(hotfix): Ignore internal attributes from conditional attributes…
Browse files Browse the repository at this point in the history
… removal (visibilityCondition) (#59)

* fix(dynamicInternalJsfAttrs): add visibilityCondition attrib;

* Release 0.7.5-dev.20231115020835

* Revert back to 0.7.4-beta.0

---------

Co-authored-by: Dilvane Zanardine <[email protected]>
  • Loading branch information
dilvane and dilvane authored Nov 15, 2023
1 parent 8089d41 commit 57fe446
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const dynamicInternalJsfAttrs = [
// HOTFIX/TODO Internal customizations, check test conditions.test.js for more info.
'Component',
'calculateDynamicProperties',
'visibilityCondition',
];
const dynamicInternalJsfAttrsObj = Object.fromEntries(
dynamicInternalJsfAttrs.map((k) => [k, true])
Expand Down
10 changes: 8 additions & 2 deletions src/tests/conditions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ describe('Conditional attributes updated', () => {
expect(fields[1].isVisible).toBe(false);
});

it('Keeps internal attributes (fieldAttrsFromJsf)', () => {
it('Keeps internal attributes (dynamicInternalJsfAttrs)', () => {
// This is necessary while we keep supporting "type", even if deprecated
// otherwise our Remote app will break because it didn't migrate
// from "type" to "inputType" yet.
Expand Down Expand Up @@ -359,7 +359,7 @@ describe('Conditional attributes updated', () => {
});
});

it('Keeps custom attribute Component (fieldAttrsFromJsf) (hotfix temporary)', () => {
it('Keeps custom attributes (dynamicInternalJsfAttrs) (hotfix temporary)', () => {
// This is necessary as hotfix because we (Remote) use it internally.
// Not cool, we'll need a better solution asap.
const { fields, handleValidation } = createHeadlessForm(
Expand Down Expand Up @@ -415,5 +415,11 @@ describe('Conditional attributes updated', () => {
handleValidation({ is_full_time: 'no' });
expect(fields[1].Component).toBe('<A React Component>');
expect(fields[1].calculateDynamicProperties).toEqual(expect.any(Function));

expect(fields[1].visibilityCondition).toEqual(undefined);
// visibilityCondition can be externally changed/updated/added, it stays there too;
fields[1].visibilityCondition = () => false;
handleValidation({ is_full_time: 'no' });
expect(fields[1].visibilityCondition).toEqual(expect.any(Function));
});
});

0 comments on commit 57fe446

Please sign in to comment.