From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 882E71FF15E for ; Mon, 15 Sep 2025 13:29:00 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A5B92218ED; Mon, 15 Sep 2025 13:29:06 +0200 (CEST) From: Dominik Csapak To: yew-devel@lists.proxmox.com Date: Mon, 15 Sep 2025 13:28:59 +0200 Message-ID: <20250915112903.2804703-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [yew-devel] [PATCH yew-widget-toolkit] widget: form: number: set 'inputmode' attribute X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" Even for Number fields, the 'type' attribute is set to 'text' to handle invalid value/state properly. To help mobile browsers use the correct software keyboard (e.g. a special one for number input) use the 'inputmode' attribute[0]. For this we have to add an 'is_decimal' function to the NumberTypeInfo trait, so we can decide if we want to set 'decimal' or 'numeric'. 0: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#inputmode Signed-off-by: Dominik Csapak --- src/widget/form/number.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/widget/form/number.rs b/src/widget/form/number.rs index d3a5409..c16c099 100644 --- a/src/widget/form/number.rs +++ b/src/widget/form/number.rs @@ -39,6 +39,8 @@ pub trait NumberTypeInfo: fn step_up(&self, step: Option) -> Self; fn clamp_value(&self, min: Option, max: Option) -> Self; + + fn is_decimal() -> bool; } impl NumberTypeInfo for f64 { @@ -72,6 +74,9 @@ impl NumberTypeInfo for f64 { fn clamp_value(&self, min: Option, max: Option) -> Self { self.clamp(min.unwrap_or(f64::MIN), max.unwrap_or(f64::MAX)) } + fn is_decimal() -> bool { + true + } } // Note: Error message from rust parse() are not gettext translated, so try to do all @@ -149,6 +154,9 @@ macro_rules! signed_number_impl { fn clamp_value(&self, min: Option, max: Option) -> Self { (*self).clamp(min.unwrap_or(<$T>::MIN), max.unwrap_or(<$T>::MAX)) } + fn is_decimal() -> bool { + false + } } }; } @@ -225,6 +233,9 @@ macro_rules! unsigned_number_impl { fn clamp_value(&self, min: Option, max: Option) -> Self { (*self).clamp(min.unwrap_or(<$T>::MIN), max.unwrap_or(<$T>::MAX)) } + fn is_decimal() -> bool { + false + } } }; } @@ -625,6 +636,12 @@ impl ManagedField for NumberField { Msg::Update(input.value()) }); + let inputmode = if T::is_decimal() { + "decimal" + } else { + "numeric" + }; + let disabled = props.input_props.disabled; let input: Html = Input::new() .with_input_props(&props.input_props) @@ -634,6 +651,7 @@ impl ManagedField for NumberField { .attribute("value", value_text) .attribute("aria-valuemin", props.min.map(|v| v.to_string())) .attribute("aria-valuemax", props.max.map(|v| v.to_string())) + .attribute("inputmode", inputmode) .oninput(oninput) .onkeydown({ let link = ctx.link(); -- 2.47.3 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel