Skip to content

Conversation

@gausszhou
Copy link
Contributor

@gausszhou gausszhou commented Dec 18, 2025

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

不支持设置 headerDragable 属性

Issue Number: N/A

What is the new behavior?

支持设置 headerDragable 属性

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

其实这里 Dragable 是个错别字,为了和旧 API footerDragale 风格保持一致,将错就错。

Summary by CodeRabbit

  • New Features

    • Added header-dragable option to the modal component, allowing control over whether the modal header can be dragged (enabled by default).
  • Changes

    • Updated default behavior: modal footer dragging is now disabled by default in examples and documentation (previously enabled).
  • Documentation

    • Enhanced modal documentation to describe header and footer dragging capabilities.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions github-actions bot added the enhancement New feature or request (功能增强) label Dec 18, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

Walkthrough

A new headerDragable prop is added to the modal component, enabling conditional control over header dragging behavior. The feature is implemented across the component definition, Vue template, API configuration, demo files, and documentation, with default behavior changed to disable header dragging by default.

Changes

Cohort / File(s) Summary
Core Modal Component Implementation
packages/vue/src/modal/src/index.ts, packages/vue/src/modal/src/pc.vue
Added headerDragable (Boolean, default: true) prop to modalProps and conditionally binds mousedown event on header: when true, triggers drag; when false, uses no-op function.
API Definition
examples/sites/demos/apis/modal.js
Added header-dragable prop (boolean, default: false) to modal component API with locale descriptions; changed footer-dragable default from true to false.
Demo Implementation
examples/sites/demos/pc/app/modal/modal-header.vue
Binds header-dragable="false" prop to TinyModal component and updates Modal.alert call to include headerDragable: false in options.
Documentation
examples/sites/demos/pc/app/modal/webdoc/modal.js
Updates documentation to describe header-dragable and footer-dragable properties; adds descriptions for dragging the modal by header or footer; corrects formatting and aligns property naming conventions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify consistency of prop naming (headerDragable vs. header-dragable) across files
  • Confirm conditional logic in pc.vue correctly implements the enable/disable behavior for header dragging
  • Check API defaults align across all files (header-dragable default: false in API config, true in core implementation)

Poem

🐰 A header now drags when you wish it to move,
A toggle so gentle, a feature to soothe,
No more forced dragging from header so high,
Control in your paws—let the modal comply!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately describes the main change: adding support for setting the headerDragable property to the modal component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
examples/sites/demos/pc/app/modal/webdoc/modal.js (1)

79-87: Documentation inconsistency: default value conflict.

The Chinese documentation states the default value for header-dragable is true (line 81), which matches the component definition but conflicts with the API documentation in examples/sites/demos/apis/modal.js that specifies defaultValue: 'false'.

Additionally, the English translation (lines 84-87) is incomplete and doesn't mention the header-dragable property at all.

Action required:

  1. Align the default value documentation with the actual component behavior
  2. Add complete English translation for the header-dragable property
🔎 Update English documentation:
         'en-US': `
           Use the <code>show-header</code> property to set whether to display headers. The default value is <code>true</code><br>
+          Use the <code>header-dragable</code> property to set whether the header can be dragged. The default value is <code>true</code><br>
           Set the title of the window through the <code>title</code> property. <br>
         `
🧹 Nitpick comments (1)
packages/vue/src/modal/src/index.ts (1)

99-99: Fix misspelling: "Dragable" should be "Draggable"

This is not an intentional naming convention. Verification shows the entire codebase uses the correct "Draggable" spelling: tree, dialog-box, popeditor, toggle-menu, tabs, tree-menu, drawer, and 15+ other components all use "draggable". The modal component is the only outlier with the misspelled "dragable" variant.

Rename headerDragable to headerDraggable and footerDragable to footerDraggable across:

  • Component props in packages/vue/src/modal/src/index.ts
  • Template usage in packages/vue/src/modal/src/pc.vue
  • Demo files and API documentation
  • Type definitions
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 851cab3 and 35e9403.

📒 Files selected for processing (5)
  • examples/sites/demos/apis/modal.js (1 hunks)
  • examples/sites/demos/pc/app/modal/modal-header.vue (2 hunks)
  • examples/sites/demos/pc/app/modal/webdoc/modal.js (2 hunks)
  • packages/vue/src/modal/src/index.ts (1 hunks)
  • packages/vue/src/modal/src/pc.vue (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (4)
packages/vue/src/modal/src/pc.vue (2)

69-69: LGTM: Prop correctly added to component.

The headerDragable prop is properly included in the props array.


178-178: LGTM: Conditional drag behavior implemented correctly.

The mousedown handler is correctly bound conditionally based on the headerDragable prop value. When headerDragable is true, the header can be dragged via this.mousedownEvent; when false, an empty function disables dragging.

This implementation is consistent with the footerDragable pattern at line 289.

examples/sites/demos/pc/app/modal/webdoc/modal.js (1)

98-111: LGTM: footer-dragable documentation updated consistently.

The documentation correctly describes the footer-dragable property and its default value of false in both Chinese and English, with proper formatting and clear explanations.

examples/sites/demos/apis/modal.js (1)

116-125: Review the default value type for footer-dragable in the API documentation.

The footer-dragable property has defaultValue: 'false' as a string instead of the boolean false. The component prop definition in index.ts declares it as footerDragable: Boolean, so the API documentation should use a boolean value for consistency. Additionally, existing demos that use this feature (e.g., modal-footer.vue) explicitly set footerDragable: true, which suggests the documented default of false is intentional and already aligned with current behavior.

Comment on lines +126 to +136
{
name: 'header-dragable',
type: 'boolean',
defaultValue: 'false',
desc: {
'zh-CN': '控制标题可拖拽',
'en-US': 'Control header dragable'
},
mode: ['pc'],
pcDemo: 'modal-header'
},
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: API documentation default value conflicts with component definition.

The API documentation specifies defaultValue: 'false' for header-dragable, but the component definition in packages/vue/src/modal/src/index.ts (line 99) has default: true. This inconsistency will confuse users about the actual default behavior.

Action required: Align the default value across component definition and API documentation. Based on the context:

  • The demo explicitly sets headerDragable: false to disable dragging
  • This suggests the default should be true (dragging enabled)
  • Update this API doc to reflect defaultValue: 'true'
🔎 Apply this fix if default should be true:
         {
           name: 'header-dragable',
           type: 'boolean',
-          defaultValue: 'false',
+          defaultValue: 'true',
           desc: {
             'zh-CN': '控制标题可拖拽',
             'en-US': 'Control header dragable'
           },
           mode: ['pc'],
           pcDemo: 'modal-header'
         },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
name: 'header-dragable',
type: 'boolean',
defaultValue: 'false',
desc: {
'zh-CN': '控制标题可拖拽',
'en-US': 'Control header dragable'
},
mode: ['pc'],
pcDemo: 'modal-header'
},
{
name: 'header-dragable',
type: 'boolean',
defaultValue: 'true',
desc: {
'zh-CN': '控制标题可拖拽',
'en-US': 'Control header dragable'
},
mode: ['pc'],
pcDemo: 'modal-header'
},
🤖 Prompt for AI Agents
In examples/sites/demos/apis/modal.js around lines 126 to 136, the API doc sets
defaultValue: 'false' for header-dragable but the component's prop default in
packages/vue/src/modal/src/index.ts (line 99) is true; update the API
documentation to defaultValue: 'true' so it matches the component (or
alternatively change the component default to false if you intend docs to be
source of truth) — make the values consistent and ensure the string boolean is
'true' in the doc.

Comment on lines +10 to +18
<tiny-modal
v-model="show"
title="自定义弹窗标题"
message="窗口内容"
show-header
show-footer
:header-dragable="false"
>
</tiny-modal>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Demo disables the feature it's meant to showcase.

The demo sets :header-dragable="false", which disables header dragging. If the purpose of this demo is to showcase the new header-dragable feature, it would be more intuitive to demonstrate the feature enabled (set to true) so users can interact with draggable headers.

Recommendation: Consider one of these approaches:

  1. Set header-dragable="true" to demonstrate the dragging capability
  2. Show both enabled and disabled states with two separate modals
  3. Add explanatory text indicating this demo shows how to disable dragging
🔎 Option 1: Enable the feature in the demo:
       <tiny-modal
         v-model="show"
         title="自定义弹窗标题"
         message="窗口内容"
         show-header
         show-footer
-        :header-dragable="false"
+        :header-dragable="true"
       >
       </tiny-modal>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<tiny-modal
v-model="show"
title="自定义弹窗标题"
message="窗口内容"
show-header
show-footer
:header-dragable="false"
>
</tiny-modal>
<tiny-modal
v-model="show"
title="自定义弹窗标题"
message="窗口内容"
show-header
show-footer
:header-dragable="true"
>
</tiny-modal>
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/modal/modal-header.vue around lines 10 to 18 the
demo unnecessarily disables the feature it intends to showcase by setting
:header-dragable="false"; change the demo to demonstrate the draggable header by
setting header-dragable to true (or add a second modal demonstrating both true
and false, or add text explaining this one shows the disabled state) so users
can see the drag behavior — update the prop to true or add the alternate
modal/text accordingly.

Comment on lines +38 to +44
Modal.alert({
message: '窗口内容',
title: '自定义弹窗标题',
showHeader: true,
showFooter: true,
headerDragable: false
})
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Demo disables the feature in functional call as well.

Similar to the template usage, the functional call also sets headerDragable: false, which disables the dragging feature. For a feature introduction demo, it would be more effective to show the feature enabled.

🔎 Consider enabling the feature:
       Modal.alert({
         message: '窗口内容',
         title: '自定义弹窗标题',
         showHeader: true,
         showFooter: true,
-        headerDragable: false
+        headerDragable: true
       })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Modal.alert({
message: '窗口内容',
title: '自定义弹窗标题',
showHeader: true,
showFooter: true,
headerDragable: false
})
Modal.alert({
message: '窗口内容',
title: '自定义弹窗标题',
showHeader: true,
showFooter: true,
headerDragable: true
})
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/modal/modal-header.vue around lines 38 to 44, the
functional demo call disables dragging by setting headerDragable: false; update
this to enable the feature (set headerDragable: true or remove the property if
true is the default) so the demo demonstrates draggable headers as intended.

customClass: String, // mf 属性
confirmBtnProps: { type: Object, default: () => ({}) },
cancelBtnProps: { type: Object, default: () => ({}) },
headerDragable: { type: Boolean, default: true },
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Find the files mentioned in the review
echo "=== Looking for the component index.ts file ==="
fd "index.ts" packages/vue/src/modal/src 2>/dev/null || echo "Not found in expected path"

echo ""
echo "=== Looking for the modal API docs ==="
fd "modal.js" examples/sites/demos/apis 2>/dev/null || echo "Not found in expected path"

echo ""
echo "=== Looking for modal-header.vue demo ==="
fd "modal-header.vue" examples/sites/demos 2>/dev/null || echo "Not found in expected path"

Repository: opentiny/tiny-vue

Length of output: 313


🏁 Script executed:

#!/bin/bash

echo "=== packages/vue/src/modal/src/index.ts (around line 99) ==="
sed -n '90,110p' packages/vue/src/modal/src/index.ts

echo ""
echo "=== examples/sites/demos/apis/modal.js (around line 129) ==="
sed -n '120,140p' examples/sites/demos/apis/modal.js

echo ""
echo "=== examples/sites/demos/pc/app/modal/modal-header.vue ==="
cat examples/sites/demos/pc/app/modal/modal-header.vue

Repository: opentiny/tiny-vue

Length of output: 2404


🏁 Script executed:

#!/bin/bash

echo "=== Confirming headerDragable default values ==="
echo ""
echo "1. Component definition (index.ts):"
grep -n "headerDragable" packages/vue/src/modal/src/index.ts | head -1

echo ""
echo "2. API documentation (modal.js):"
grep -n "header-dragable" examples/sites/demos/apis/modal.js -A 3 | head -4

echo ""
echo "3. Summary:"
echo "Component default: true (Boolean)"
echo "API docs default: 'false' (string)"
echo "Inconsistency: CONFIRMED"

Repository: opentiny/tiny-vue

Length of output: 471


Default value mismatch between component definition and API documentation.

The component sets default: true for headerDragable, but the API documentation in examples/sites/demos/apis/modal.js (line 129) specifies defaultValue: 'false'. The demo in modal-header.vue explicitly sets headerDragable: false in both the template and function call, which corroborates that the intended default is true (dragging enabled by default).

Update the API documentation to match the component definition:

-          defaultValue: 'false',
+          defaultValue: 'true',

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/vue/src/modal/src/index.ts around line 99 the prop headerDragable is
defined with default: true but the API docs in
examples/sites/demos/apis/modal.js declare defaultValue: 'false'; update the API
documentation to match the component by changing the defaultValue in
examples/sites/demos/apis/modal.js (near line 129) to 'true' (or the boolean
true representation used in that file) so the docs reflect the actual component
default.

{
name: 'header-dragable',
type: 'boolean',
defaultValue: 'false',
Copy link
Member

Choose a reason for hiding this comment

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

你好,这里的默认值应该是true,还有新加的特性需要补充下版本信息哈

Copy link
Member

Choose a reason for hiding this comment

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

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

Labels

enhancement New feature or request (功能增强)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants