From 5bfe5926d0d94719db6898065d354ce021eafdfb Mon Sep 17 00:00:00 2001 From: Vaadin Bot Date: Mon, 30 Sep 2024 12:25:26 +0200 Subject: [PATCH] fix: ensure has-value attribute is set on custom-value (#7885) (#7886) Co-authored-by: Serhii Kulykov --- 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', () => {