From 2e2c3fb0b68af774f827df6c3dad61986e5462cf Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 16 Nov 2023 13:13:36 -0700 Subject: [PATCH] Fix validation messages after Shoelace update - some messages (textbox) were out of position - Selectboxes did not show validation message - Selectbox considered false a valid value for required, even if that wasn't an option --- api/js/etemplate/Et2InputWidget/Et2InputWidget.ts | 5 ++++- api/js/etemplate/Et2Select/Et2Select.ts | 5 ++++- api/templates/default/etemplate2.css | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts b/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts index 0a1c1a1baf..7f22574716 100644 --- a/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts +++ b/api/js/etemplate/Et2InputWidget/Et2InputWidget.ts @@ -7,6 +7,9 @@ import {LionValidationFeedback, Validator} from "@lion/form-core"; import {et2_csvSplit} from "../et2_core_common"; import {dedupeMixin} from "@lion/core"; +// LionValidationFeedback needs to be registered manually +window.customElements.define('lion-validation-feedback', LionValidationFeedback); + /** * This mixin will allow any LitElement to become an Et2InputWidget * @@ -87,7 +90,7 @@ const Et2InputWidgetMixin = >(superclass : T) width: 100%; } - .form-field__feedback { + .form-control__help-text { position: relative; } ` diff --git a/api/js/etemplate/Et2Select/Et2Select.ts b/api/js/etemplate/Et2Select/Et2Select.ts index fa58a1c728..30dcfcb389 100644 --- a/api/js/etemplate/Et2Select/Et2Select.ts +++ b/api/js/etemplate/Et2Select/Et2Select.ts @@ -327,7 +327,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect) } // emptyLabel is fine - if(!(this.value) && this.value !== '0' && (this.emptyLabel || this.placeholder)) + if((this.value == '' || this.value == []) && (this.emptyLabel || this.placeholder)) { return; } @@ -856,6 +856,9 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect) ${this._optionsTemplate()} ${this._extraTemplate()} +
+ +
`; } diff --git a/api/templates/default/etemplate2.css b/api/templates/default/etemplate2.css index fe24f73aba..1a883069ad 100644 --- a/api/templates/default/etemplate2.css +++ b/api/templates/default/etemplate2.css @@ -2130,6 +2130,8 @@ div.message.floating, lion-validation-feedback[type] { lion-validation-feedback[type] { top: initial; margin-top: calc(-0.2 * var(--sl-input-height-medium)); + width: fit-content; + white-space: nowrap; } .message.validation_error, lion-validation-feedback[type="error"] {