Skip to content

Conversation

@edimitchel
Copy link
Contributor

πŸ”— Linked issue

Resolves #5882

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Adding range prop to UInputTime in order to select time ranges.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

<!-- Single mode -->
<TimeFieldRoot
v-bind="{ ...rootProps, ...ariaAttrs }"
v-else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In non-range mode, the TimeFieldRoot component doesn't receive the modelValue and defaultValue props, causing the component to fail to work when a time value is provided.

View Details
πŸ“ Patch Details
diff --git a/src/runtime/components/InputTime.vue b/src/runtime/components/InputTime.vue
index cdb6a9a1..9cb591b2 100644
--- a/src/runtime/components/InputTime.vue
+++ b/src/runtime/components/InputTime.vue
@@ -289,6 +289,8 @@ defineExpose({
     v-bind="{ ...rootProps, ...$attrs, ...ariaAttrs }"
     :id="id"
     v-slot="{ segments }"
+    :model-value="modelValue"
+    :default-value="defaultValue"
     :name="name"
     :disabled="disabled"
     data-slot="base"

Analysis

Missing modelValue and defaultValue bindings in InputTime non-range mode

What fails: InputTime component in non-range mode does not properly bind the modelValue and defaultValue props to the TimeFieldRoot component, causing controlled time values to be ignored.

How to reproduce:

<InputTime :modelValue="new Time(14, 30)" />

The component will render empty time inputs instead of displaying 14:30.

Root cause: Line 102 uses reactiveOmit(props, ..., 'modelValue', 'defaultValue', ...) to remove these props from rootProps. However, in the non-range mode template (lines 287-299), the component spreads rootProps but does not explicitly bind :model-value and :default-value, unlike:

  • The range mode implementation (lines 235-248, 254-267) which explicitly binds :model-value="startValue" and :default-value="startDefaultValue"
  • InputDate.vue which explicitly binds :model-value="(modelValue as DateValue)" and :default-value="(defaultValue as DateValue)"
  • Calendar.vue which explicitly binds :model-value and :default-value"

Fix: Add explicit bindings to the non-range TimeFieldRoot:

:model-value="modelValue"
:default-value="defaultValue"

This ensures the component properly handles controlled values in non-range mode, matching the pattern established in similar components (InputDate, Calendar) and the range mode implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The model value is passed from rootProps, isn't ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UInputTime] Add range prop to handle time range

1 participant