Skip to content

Commit

Permalink
fix: ensure has-value attribute is set on custom-value (#7885)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Sep 30, 2024
1 parent ff28e96 commit 9c57813
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/custom-field/src/vaadin-custom-field-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ export const CustomFieldMixin = (superClass) =>

/** @private */
__valueChanged(value, oldValue) {
this.__toggleHasValue(value);

if (this.__settingValue || !this.inputs) {
return;
}

this.__toggleHasValue(value);

const parseFn = this.parseValue || defaultParseValue;
const valuesArray = parseFn.apply(this, [value]);
if (!valuesArray || valuesArray.length === 0) {
Expand Down
9 changes: 9 additions & 0 deletions packages/custom-field/test/custom-field.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ describe('custom field', () => {
expect(el.value).to.equal('1');
});
});

it('should set has-value when updating values', async () => {
customField.inputs.forEach((el) => {
el.value = '1';
fire(el, 'change');
});
await nextUpdate(customField);
expect(customField.hasAttribute('has-value')).to.be.true;
});
});

describe('aria-required', () => {
Expand Down

0 comments on commit 9c57813

Please sign in to comment.