Skip to content

Commit

Permalink
fix: restore default node correctly when using helperText (#7449) (#7451
Browse files Browse the repository at this point in the history
)

Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
  • Loading branch information
vaadin-bot and web-padawan authored May 27, 2024
1 parent 9f692f8 commit 8311891
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit 8311891

Please sign in to comment.