From 49acb224907ba94c3cb30f843a198db8634511e2 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 25 Jul 2024 09:54:38 -0600 Subject: [PATCH] Calendar: Fix unable to save events on mobile --- api/js/etemplate/Et2Date/Et2Date.ts | 40 ++++++++++------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/api/js/etemplate/Et2Date/Et2Date.ts b/api/js/etemplate/Et2Date/Et2Date.ts index a2b7a8817c..aef36b4376 100644 --- a/api/js/etemplate/Et2Date/Et2Date.ts +++ b/api/js/etemplate/Et2Date/Et2Date.ts @@ -385,29 +385,6 @@ export class Et2Date extends Et2InputWidget(LitFlatpickr) } } - get slots() - { - return { - ...super.slots, - input: () => - { - if(typeof egwIsMobile == "function" && egwIsMobile()) - { - // Plain input for mobile - const text = document.createElement('input'); - text.type = this._mobileInputType(); - return text; - } - // This element gets hidden and used for value, but copied by flatpicr and used for input - const text = document.createElement('et2-textbox'); - text.type = "text"; - text.placeholder = this.placeholder; - text.required = this.required; - return text; - } - } - } - constructor() { super(); @@ -626,6 +603,10 @@ export class Et2Date extends Et2InputWidget(LitFlatpickr) { value = ""; this.clear(); + if(typeof egwIsMobile == "function" && egwIsMobile() && this._inputNode) + { + this._inputNode.value = ''; + } return; } let date; @@ -968,9 +949,16 @@ export class Et2Date extends Et2InputWidget(LitFlatpickr) * This is an et2-textbox, which causes some problems with flatpickr * @protected */ - get _inputNode() : Et2Textbox + get _inputNode() : Et2Textbox | HTMLInputElement { - return this.shadowRoot?.querySelector('et2-textbox'); + if(typeof egwIsMobile == "function" && egwIsMobile()) + { + return this.shadowRoot?.querySelector("input[type='" + this._mobileInputType() + "']"); + } + else + { + return this.shadowRoot?.querySelector('et2-textbox'); + } } /** @@ -1087,7 +1075,7 @@ export class Et2Date extends Et2InputWidget(LitFlatpickr) const helpTemplate = this._helpTextTemplate(); return html` - ${super.render()} + ${(typeof egwIsMobile != "function" || !egwIsMobile()) ? super.render() : nothing}