Skip to content

Commit 9c57813

Browse files
authored
fix: ensure has-value attribute is set on custom-value (#7885)
1 parent ff28e96 commit 9c57813

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/custom-field/src/vaadin-custom-field-mixin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,12 @@ export const CustomFieldMixin = (superClass) =>
259259

260260
/** @private */
261261
__valueChanged(value, oldValue) {
262+
this.__toggleHasValue(value);
263+
262264
if (this.__settingValue || !this.inputs) {
263265
return;
264266
}
265267

266-
this.__toggleHasValue(value);
267-
268268
const parseFn = this.parseValue || defaultParseValue;
269269
const valuesArray = parseFn.apply(this, [value]);
270270
if (!valuesArray || valuesArray.length === 0) {

packages/custom-field/test/custom-field.common.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ describe('custom field', () => {
6868
expect(el.value).to.equal('1');
6969
});
7070
});
71+
72+
it('should set has-value when updating values', async () => {
73+
customField.inputs.forEach((el) => {
74+
el.value = '1';
75+
fire(el, 'change');
76+
});
77+
await nextUpdate(customField);
78+
expect(customField.hasAttribute('has-value')).to.be.true;
79+
});
7180
});
7281

7382
describe('aria-required', () => {

0 commit comments

Comments
 (0)