fix(Slider): emit a number for a single thumb - #6890
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe Slider root now calls Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change restores single-thumb sliders to emitting a number while preserving array output for multi-thumb sliders. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Linked Issues checkExplanation The change removes duplicate update:modelValue forwarding and preserves the sliderValue number transformation. The added tests verify number emission for single-thumb sliders and array emission for multiple-thumb sliders, satisfying issue Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
src/runtime/components/Slider.vueParsing error: Unexpected token ) test/components/Slider.spec.tsParsing error: Unexpected token { Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
🔗 Linked issue
Resolves #6889
❓ Type of change
📚 Description
Since v4.11.0 a single-thumb
USliderwrites[71]back intov-modelinstead of71.Sliderkeeps the model insliderValue, a computed that wraps a number into an array for Reka UI on the way in and unwraps a one-element array on the way out. That setter is what decides the shape the component emits. ButrootPropsis built withuseForwardProps(..., emits), anduseEmitAsPropswalks the component's declared emits, which include theupdate:modelValuethatdefineModeladds.SliderRoottherefore also got anonUpdate:modelValuethat re-emits Reka UI's raw array to the parent.Both handlers have always been bound, so the value the parent kept was whichever one ran last. #6848 moved
v-bindafterv-modelonSliderRoot, which flipped that order and let the raw array win. The duplicate emit is visible in the existing test, which asserted{ 'update:modelValue': [[1], [1]] }.Dropping
emitsfrom thatuseForwardPropscall removes the extra handler.update:modelValueis already wired throughv-model="sliderValue"and@update:model-value="emitFormInput()", andchangecomes fromonChangeon@value-commit, so nothing else was relying on it.📝 Checklist