100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Drop the autoresized height when manualresize takes over (#3395)
Koen438635e5ebb1
diff --git a/ui/component/or-vaadin-components/src/or-vaadin-text-area.ts b/ui/component/or-vaadin-components/src/or-vaadin-text-area.tsindex f932deac4..e7b930705 100644--- a/ui/component/or-vaadin-components/src/or-vaadin-text-area.ts+++ b/ui/component/or-vaadin-components/src/or-vaadin-text-area.ts@@ -76,6 +76,11 @@ export class OrVaadinTextAreasuper.updated(changedProperties);// _updateHeight only runs on value changes; re-apply when the mode toggles.if (changedProperties.has("manualresize")) {+ if (this.manualresize) {+ // A value that arrived first was autoresized, so drop that inline height and let+ // min-rows govern again. From here on only a resize drag writes one, and it stays.+ this.inputElement?.style.removeProperty("height");+ }this._updateHeight();}}diff --git a/ui/component/or-vaadin-components/test/fixtures/value-input-provider-harness.js b/ui/component/or-vaadin-components/test/fixtures/value-input-provider-harness.jsindex 0f421e48d..6085459f6 100644--- a/ui/component/or-vaadin-components/test/fixtures/value-input-provider-harness.js+++ b/ui/component/or-vaadin-components/test/fixtures/value-input-provider-harness.js@@ -33,13 +33,22 @@ export class ValueInputProviderHarness extends LitElement {value: {},constraints: { type: Array },format: { type: Object },+ multiline: { type: Boolean },+ options: { type: Object },};willUpdate(changed) {- if (changed.has("valueType") || changed.has("constraints") || changed.has("format")) {+ if (+ changed.has("valueType") ||+ changed.has("constraints") ||+ changed.has("format") ||+ changed.has("multiline") ||+ changed.has("options")+ ) {const meta = {};if (this.constraints) meta.constraints = this.constraints;if (this.format) meta.format = this.format;+ if (this.multiline) meta.multiline = true;const attribute = { name: "attribute", type: this.valueType, meta };const [attributeDescriptor, valueDescriptor] = AssetModelUtil.getAttributeAndValueDescriptors("ThingAsset",@@ -52,7 +61,7 @@ export class ValueInputProviderHarness extends LitElement {attributeDescriptor,valueDescriptor,(value) => this.dispatchEvent(new CustomEvent("value-change", { detail: value })),- { label: "Attribute" }+ { label: "Attribute", ...this.options });}}diff --git a/ui/component/or-vaadin-components/test/or-vaadin-text-area.test.ts b/ui/component/or-vaadin-components/test/or-vaadin-text-area.test.tsindex 8579e55ad..44e7a70d9 100644--- a/ui/component/or-vaadin-components/test/or-vaadin-text-area.test.ts+++ b/ui/component/or-vaadin-components/test/or-vaadin-text-area.test.ts@@ -98,6 +98,22 @@ ct.describe("Height", () => {await expect(input).toHaveCSS("height", "208px");});+ ct("manualresize resets an already autoresized field to min-rows", async ({ mount }) => {+ const component = await mount(OrVaadinTextArea, { props: { label: "Text", minRows: 3 } });++ const input = component.getByRole("textbox", { name: "Text" });+ const minRowsHeight = (await input.boundingBox())!.height;++ // A value that is already set reaches autoresize before the mode does, which is what a+ // page load renders.+ await component.evaluate((el, value) => el.setAttribute("value", value), lines(30));+ await expect.poll(async () => (await input.boundingBox())!.height).toBeGreaterThan(minRowsHeight);++ // The height autoresize wrote has to go, so min-rows governs again.+ await component.evaluate((el) => el.setAttribute("manualresize", ""));+ await expect.poll(async () => (await input.boundingBox())!.height).toBe(minRowsHeight);+ });+ct("the resize handle drags the textarea taller", async ({ mount, page, shared }) => {const component = await mount(OrVaadinTextArea, { props: { label: "Text", minRows: 3, manualresize: true } });diff --git a/ui/component/or-vaadin-components/test/value-input-provider.test.ts b/ui/component/or-vaadin-components/test/value-input-provider.test.tsindex 880414e3a..6bcd4b6f2 100644--- a/ui/component/or-vaadin-components/test/value-input-provider.test.ts+++ b/ui/component/or-vaadin-components/test/value-input-provider.test.ts@@ -160,3 +160,20 @@ ct("should round up a minimum that falls between two picker values", async ({ mo// The minimum used to round down to 10:30, which the picker then allowed although it is before the minimum.await expect.poll(() => values).toEqual([localTime(10, 31)]);});++ct("should keep a manually resizable text area at its min-rows height", async ({ mount }) => {+ const component = await mount(ValueInputProviderHarness, {+ props: {+ valueType: "text",+ multiline: true,+ options: { minRows: 5, manualresize: true },+ value: Array.from({ length: 30 }, (_, i) => `line ${i + 1}`).join("\n"),+ },+ });++ // The template sets the value before manualresize, so a value that is already set reaches+ // autoresize first. The thirty lines have to scroll inside the five rows.+ const textArea = component.getByRole("textbox", { name: "Attribute" });+ await expect(textArea).toHaveAttribute("rows", "5");+ await expect.poll(() => textArea.evaluate((el: HTMLTextAreaElement) => el.scrollHeight > el.clientHeight)).toBe(true);+});