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: restore default node correctly when using helperText (#7449) (CP: 24.3) #7451

Merged
merged 1 commit into from
May 27, 2024
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
2 changes: 1 addition & 1 deletion packages/component-base/src/slot-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ export class SlotController extends EventTarget {
if (slotName !== '') {
node.setAttribute('slot', slotName);
}
this.node = node;
this.defaultNode = node;
}
}

if (node) {
this.node = node;
host.appendChild(node);
}

Expand Down
11 changes: 11 additions & 0 deletions packages/field-base/test/field-mixin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,17 @@ const runTests = (defineHelper, baseMixin) => {
expect(element._helperNode).to.equal(defaultHelper);
});

it('should restore the default helper when restoring helperText immediately', async () => {
element.helperText = null;
element.appendChild(helper);
await nextRender();

element.removeChild(helper);
element.helperText = 'Updated helper';
await nextRender();
expect(element._helperNode.textContent).to.equal('Updated helper');
});

it('should keep has-helper attribute when the default helper is restored', async () => {
element.appendChild(helper);
await nextRender();
Expand Down
Loading