From 9c57813c702eeb77d39c918fbdfe8bc18cf73558 Mon Sep 17 00:00:00 2001 From: Serhii Kulykov Date: Mon, 30 Sep 2024 13:16:08 +0300 Subject: [PATCH] fix: ensure has-value attribute is set on custom-value (#7885) --- packages/custom-field/src/vaadin-custom-field-mixin.js | 4 ++-- packages/custom-field/test/custom-field.common.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/custom-field/src/vaadin-custom-field-mixin.js b/packages/custom-field/src/vaadin-custom-field-mixin.js index 720b0bff09..cf2fb328a8 100644 --- a/packages/custom-field/src/vaadin-custom-field-mixin.js +++ b/packages/custom-field/src/vaadin-custom-field-mixin.js @@ -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) { diff --git a/packages/custom-field/test/custom-field.common.js b/packages/custom-field/test/custom-field.common.js index b061b8e3d8..bebce41e2d 100644 --- a/packages/custom-field/test/custom-field.common.js +++ b/packages/custom-field/test/custom-field.common.js @@ -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', () => {