Skip to content

Commit

Permalink
fix: ensure has-value attribute is set on custom-value (#7885) (#7886)
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 Sep 30, 2024
1 parent a8ae853 commit 5bfe592
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 5bfe592

Please sign in to comment.