[yew-devel] [PATCH yew-widget-toolkit v2 1/2] number: add tooltip to number field

Hannes Laimer h.laimer at proxmox.com
Thu Oct 9 13:54:05 CEST 2025


On 10/9/25 13:51, Dominik Csapak wrote:
> 
> 
> On 10/9/25 1:24 PM, Hannes Laimer wrote:
>> Signed-off-by: Hannes Laimer <h.laimer at proxmox.com>
>> ---
>>   src/widget/form/number.rs | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/src/widget/form/number.rs b/src/widget/form/number.rs
>> index 80f7f6c..ad1a3cd 100644
>> --- a/src/widget/form/number.rs
>> +++ b/src/widget/form/number.rs
>> @@ -368,6 +368,11 @@ pub struct Number<T: NumberTypeInfo> {
>>       #[builder_cb(IntoEventCallback, into_event_callback, (String, 
>> Option<T>))]
>>       #[prop_or_default]
>>       pub on_input: Option<Callback<(String, Option<T>)>>,
>> +
>> +    /// The tooltip.
>> +    #[prop_or_default]
>> +    #[builder(IntoPropValue, into_prop_value)]
>> +    pub tip: Option<AttrValue>,
>>   }
>>   impl<T: NumberTypeInfo> Default for Number<T> {
> 
> 
> please correct me if I'm wrong, but just adding the tip to the 
> properties alone wouldn't do anything on its own.
> 
> You have to at least use it in the 'view' method, e.g. like this:
> 

Yes, that hunk slipped into the second patch

pub enum Msg {
@@ -711,8 +765,15 @@ impl<T: NumberTypeInfo> ManagedField for 
NumberField<T> {
                      ),
              );

-        if let Err(msg) = &validation_result {
-            input_container.set_tip(msg.clone())
+        match validation_result {
+            Err(msg) => input_container.set_tip(msg.clone()),
+            Ok(_) => {
+                if let Some(tip) = &props.tip {
+                    if !disabled {
+                        input_container.set_tip(tip.clone())
+                    }
+                }
+            }
          }


But I'll send another version anyway, since, as Dietmar mentioned, we
don't really want to depend on proxmox-schema here.

> 
> ---
>   let mut input_container: Tooltip = Tooltip::empty()
>       .with_std_props(&props.std_props)
>       .listeners(list: &props.listeners)
>       .tip(props.tip.clone())
> ---





More information about the yew-devel mailing list