-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(dialog-box): [dialog-box] modify demo #2472
Conversation
WalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (7)
examples/sites/demos/pc/app/dialog-box/dialog-width.spec.ts (1)
Line range hint 3-14
: Consider adding width assertions for completeness.
While the test checks the max-height property, it doesn't explicitly verify the width percentages (30% and 60%) mentioned in the button labels.
Consider adding width assertions after each dialog open:
test('dialogBox 弹窗的宽度和最大高度', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('dialog-box#dialog-width')
const dialogBox = page.locator('.tiny-dialog-box')
await page.getByRole('button', { name: /30%/ }).click()
+ await expect(dialogBox.first()).toHaveCSS('width', '30%')
await expect(dialogBox.first()).toHaveCSS('max-height', '200px')
await page.getByRole('button', { name: 'Close' }).click()
await page.getByRole('button', { name: /60%/ }).click()
+ await expect(dialogBox.nth(1)).toHaveCSS('width', '60%')
await expect(dialogBox.nth(1)).toBeVisible()
})
examples/sites/demos/pc/app/dialog-box/dialog-width.vue (2)
Line range hint 39-44
: Add missing data properties for radio groups
The radio groups require v-model bindings but no corresponding data properties exist in the component.
Add the necessary data properties:
data() {
return {
boxVisibility1: false,
boxVisibility2: false,
+ selectedProduct: 1,
+ selectedDepartment: 1
}
}
52-54
: Remove or utilize unused CSS class
The .demo-class
is defined but not used in the template. If this class is intended for the dialog content, consider the following:
- Fixed heights might cause content overflow issues
- The purpose of this class should be documented
Either remove the unused class or apply it where needed:
-<div>
+<div class="demo-class">
<tiny-radio-group>
examples/sites/demos/apis/dialog-box.js (4)
Line range hint 108-114
: Fix incorrect English description for lock-scroll prop
The English description for the lock-scroll prop is incorrect. It currently describes showing the pop-up header, which is unrelated to scroll locking functionality.
Apply this change:
desc: {
'zh-CN': 'Dialog 弹出时是否禁用滚动条',
- 'en-US': 'Indicates whether to display the pop-up header. The default value is true'
+ 'en-US': 'Whether to disable scrolling when the dialog is displayed. The default value is true'
},
Line range hint 160-169
: Fix swapped English descriptions
The English description for modal-append-to-body
is actually describing append-to-body
and vice versa. This needs to be corrected to avoid confusion.
Apply these changes:
desc: {
'zh-CN': '遮罩层是否应用到 body 上,为 false 时遮罩层会应用到 DialogBox 的父元素上',
- 'en-US': 'Indicates whether the DialogBox itself is inserted into the body. This attribute must be specified and set to true for nested Dialogs'
+ 'en-US': 'Whether to append the mask layer to body. If false, the mask layer will be appended to the parent element of DialogBox'
},
Line range hint 186-195
: Fix incorrect English description for right-slide prop
The English description for the right-slide prop is describing the lock-scroll functionality instead.
Apply this change:
desc: {
'zh-CN': '是否开启弹出右侧滑出功能',
- 'en-US': 'Whether to disable the scroll bar when a log is displayed'
+ 'en-US': 'Whether to enable the right slide-out functionality for the dialog'
},
Line range hint 212-221
: Fix incorrect English description for show-header prop
The English description for show-header is incorrectly showing "Pop-up dialog box title" instead of describing the header visibility functionality.
Apply this change:
desc: {
'zh-CN': '是否显示弹窗头部 header',
- 'en-US': 'Pop-up dialog box title'
+ 'en-US': 'Whether to display the dialog header'
},
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
- examples/sites/demos/apis/dialog-box.js (1 hunks)
- examples/sites/demos/pc/app/dialog-box/dialog-width-composition-api.vue (3 hunks)
- examples/sites/demos/pc/app/dialog-box/dialog-width.spec.ts (1 hunks)
- examples/sites/demos/pc/app/dialog-box/dialog-width.vue (3 hunks)
- examples/sites/demos/pc/app/dialog-box/webdoc/dialog-box.js (2 hunks)
🔇 Additional comments (9)
examples/sites/demos/pc/app/dialog-box/dialog-width.spec.ts (2)
3-3
: LGTM! Test name accurately reflects the expanded scope.
The updated test name properly indicates that it now covers both width and maximum height functionality.
9-9
: LGTM! Max-height assertion is well-positioned.
The new assertion is logically placed after opening the dialog but before closing it, maintaining a clear test flow. The 200px value aligns with the demo modifications mentioned in the PR.
examples/sites/demos/pc/app/dialog-box/dialog-width-composition-api.vue (2)
3-3
: LGTM! Button text accurately reflects the dialog box properties.
The button text clearly indicates both the width (30%) and maximum height (200px) of the associated dialog box.
31-31
: LGTM! Imports are correctly structured.
The new radio components are properly imported from the @opentiny/vue package.
examples/sites/demos/pc/app/dialog-box/dialog-width.vue (1)
Line range hint 1-57
: Verify consistency across dialog box demos
Since this is a demo modification, we should ensure consistent implementation across related dialog box demos.
✅ Verification successful
Both dialog-width demos are consistent, no updates needed
After verifying the implementation across dialog box demos:
- The composition API version (
dialog-width-composition-api.vue
) has identical width and max-height implementation - The webdoc confirms this is the intended behavior, documenting both
width
andmax-height
properties - No inconsistencies found in the demo implementations
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Find all dialog box demo files
echo "Checking for other dialog box demos that might need similar updates..."
fd -e vue -e jsx dialog-width examples/sites/demos/pc/app/dialog-box/
# Check for inconsistent max-height usage
echo "Checking for inconsistent max-height usage across demos..."
rg -l "max-height" examples/sites/demos/pc/app/dialog-box/
Length of output: 784
Script:
#!/bin/bash
# Check content of composition API version for consistency
echo "=== Content of dialog-width-composition-api.vue ==="
cat examples/sites/demos/pc/app/dialog-box/dialog-width-composition-api.vue
# Check webdoc for any documented requirements
echo -e "\n=== Content of dialog-box.js webdoc ==="
cat examples/sites/demos/pc/app/dialog-box/webdoc/dialog-box.js
Length of output: 13606
examples/sites/demos/apis/dialog-box.js (2)
136-136
: LGTM: pcDemo change for max-height prop
The change of pcDemo from 'form-in-dialog' to 'dialog-width' is appropriate as it better aligns with where the max-height functionality is demonstrated.
Line range hint 1-400
: Verify demo references
Several props reference demos that might need verification to ensure they correctly demonstrate the intended functionality. Please verify that all pcDemo references point to existing and appropriate demo files.
Let's verify the demo files exist:
✅ Verification successful
All demo references are correctly mapped to existing demo files
The verification process has confirmed that all pcDemo references in the dialog-box.js API documentation correctly map to existing demo files in the repository. Each referenced demo has corresponding files (both regular and composition API versions) in the examples/sites/demos/pc/app/dialog-box/ directory, along with their spec files. For example:
- basic-usage → examples/sites/demos/pc/app/dialog-box/basic-usage.vue
- center → examples/sites/demos/pc/app/dialog-box/center.vue
- close-on-click-modal → examples/sites/demos/pc/app/dialog-box/close-on-click-modal.vue
And so on for all other demo references.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if all referenced demo files exist
# Extract unique demo references and check if corresponding files exist
echo "Checking demo references..."
demos=$(grep -o 'pcDemo:.*' examples/sites/demos/apis/dialog-box.js | cut -d"'" -f2 | sort -u)
for demo in $demos; do
echo "Checking for demo: $demo"
fd -t f "$demo" examples/sites/demos/pc/
done
Length of output: 26634
examples/sites/demos/pc/app/dialog-box/webdoc/dialog-box.js (2)
114-121
: LGTM! Well-documented demo update for width and max-height properties.
The demo name and description have been appropriately updated to reflect both the width and max-height configuration options. The changes are clear and consistent in both Chinese and English translations.
248-250
: LGTM! Consistent cleanup of max-height property reference.
The removal of the max-height property from this demo's description maintains consistency with its relocation to the dialog-width demo, avoiding duplicate documentation of the feature.
<tiny-radio-group> | ||
<tiny-radio :label="0">产品</tiny-radio> | ||
</tiny-radio-group> | ||
</div> | ||
<div> | ||
<tiny-radio-group> | ||
<tiny-radio :label="0">研发</tiny-radio> | ||
</tiny-radio-group> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enhance radio groups implementation.
The current implementation of radio groups appears incomplete:
- Both radio groups have the same label value (
:label="0"
) - Missing
v-model
binding for selection state - Single radio button in each group limits functionality
Consider implementing like this:
-<tiny-radio-group>
- <tiny-radio :label="0">产品</tiny-radio>
-</tiny-radio-group>
+<tiny-radio-group v-model="selectedDepartment1">
+ <tiny-radio :label="1">产品</tiny-radio>
+ <tiny-radio :label="2">设计</tiny-radio>
+ <tiny-radio :label="3">测试</tiny-radio>
+</tiny-radio-group>
-<tiny-radio-group>
- <tiny-radio :label="0">研发</tiny-radio>
-</tiny-radio-group>
+<tiny-radio-group v-model="selectedDepartment2">
+ <tiny-radio :label="1">研发</tiny-radio>
+ <tiny-radio :label="2">运维</tiny-radio>
+ <tiny-radio :label="3">架构</tiny-radio>
+</tiny-radio-group>
Don't forget to add the corresponding reactive variables in the script section:
const selectedDepartment1 = ref(1)
const selectedDepartment2 = ref(1)
.demo-class { | ||
height: 300px; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Remove unused CSS class
The .demo-class
is defined but not used in the template of both files where it appears (dialog-width-composition-api.vue
and dialog-width.vue
). These appear to be demo files showing dialog width functionality, and the unused CSS class should be removed to maintain clean code.
- Remove
.demo-class { height: 300px; }
fromexamples/sites/demos/pc/app/dialog-box/dialog-width-composition-api.vue
- Remove
.demo-class { height: 300px; }
fromexamples/sites/demos/pc/app/dialog-box/dialog-width.vue
🔗 Analysis chain
Verify usage of unused CSS class.
The .demo-class
is defined but not used in the template. If this class is not needed, consider removing it.
Let's check if this class is used elsewhere:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for demo-class usage in the codebase
rg "demo-class" --type vue
Length of output: 54
Script:
#!/bin/bash
# Search for demo-class usage in all files
rg "demo-class"
# Also search with different case variations to be thorough
rg -i "demo-?class"
# Let's also check the specific file content to understand the context
cat "examples/sites/demos/pc/app/dialog-box/dialog-width-composition-api.vue"
Length of output: 1728
Script:
#!/bin/bash
# Let's check the content of the other file that has demo-class
cat "examples/sites/demos/pc/app/dialog-box/dialog-width.vue"
Length of output: 1462
<tiny-radio-group> | ||
<tiny-radio :label="0">产品</tiny-radio> | ||
</tiny-radio-group> | ||
</div> | ||
<div> | ||
<tiny-radio-group> | ||
<tiny-radio :label="0">研发</tiny-radio> | ||
</tiny-radio-group> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve radio groups implementation and accessibility
The current implementation of radio groups has several issues:
- Both radio groups have identical labels (
:label="0"
) - Each group contains only one option, which defeats the purpose of radio groups
- Missing accessibility attributes
Consider applying these improvements:
-<tiny-radio-group>
- <tiny-radio :label="0">产品</tiny-radio>
-</tiny-radio-group>
+<tiny-radio-group v-model="selectedProduct" aria-label="Product Selection">
+ <tiny-radio :label="1">产品</tiny-radio>
+ <tiny-radio :label="2">设计</tiny-radio>
+</tiny-radio-group>
-<tiny-radio-group>
- <tiny-radio :label="0">研发</tiny-radio>
-</tiny-radio-group>
+<tiny-radio-group v-model="selectedDepartment" aria-label="Department Selection">
+ <tiny-radio :label="1">研发</tiny-radio>
+ <tiny-radio :label="2">测试</tiny-radio>
+</tiny-radio-group>
Committable suggestion was skipped due to low confidence.
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
max-height
property and enhanced descriptions for better clarity.Bug Fixes
Tests
max-height
functionality in the dialog box.