Skip to content
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

Merged
merged 1 commit into from
Nov 2, 2024
Merged

Conversation

James-9696
Copy link
Collaborator

@James-9696 James-9696 commented Oct 30, 2024

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?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Updated dialog box component with a new max-height property and enhanced descriptions for better clarity.
    • Added radio button options within the dialog box for improved user interaction.
  • Bug Fixes

    • Clarified descriptions for existing properties to ensure accurate usage guidance.
  • Tests

    • Updated test cases to include assertions for the new max-height functionality in the dialog box.

@github-actions github-actions bot added the bug Something isn't working label Oct 30, 2024
Copy link

coderabbitai bot commented Oct 30, 2024

Walkthrough

The pull request introduces modifications to the dialog-box component's API and related demo files. Key changes include updating the pcDemo property for the max-height attribute and enhancing descriptions for the lock-scroll prop. Additionally, the dialog-width-composition-api.vue file has been updated to include new radio button components and a maximum height setting. Test cases have been adjusted to reflect these changes, and demo descriptions have been refined for clarity. Overall, the changes focus on improving the API specifications and demo clarity without altering the existing functionality.

Changes

File Path Change Summary
examples/sites/demos/apis/dialog-box.js Updated pcDemo for max-height from 'form-in-dialog' to 'dialog-width'; clarified lock-scroll prop description.
examples/sites/demos/pc/app/dialog-box/dialog-width-composition-api.vue Button text updated; added max-height to tiny-dialog-box; included new tiny-radio-group components; added scoped CSS.
examples/sites/demos/pc/app/dialog-box/dialog-width.spec.ts Test name updated to reflect width and max height; added assertion for max height of 200 pixels.
examples/sites/demos/pc/app/dialog-box/dialog-width.vue Updated button text; added max-height to tiny-dialog-box; included new TinyRadio and TinyRadioGroup components; added scoped CSS.
examples/sites/demos/pc/app/dialog-box/webdoc/dialog-box.js Updated demo descriptions for dialog-width and form-in-dialog to clarify width and max-height properties.

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

🐰 In the meadow, changes bloom,
Dialogs dance, dispelling gloom.
With width and height, they now align,
New buttons and radios, oh so fine!
A hop, a skip, let’s celebrate,
In our code, we innovate! 🌼


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 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:

  1. Fixed heights might cause content overflow issues
  2. 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

📥 Commits

Files that changed from the base of the PR and between 299d7fe and 088e288.

📒 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 and max-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.

Comment on lines +7 to +14
<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>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Enhance radio groups implementation.

The current implementation of radio groups appears incomplete:

  1. Both radio groups have the same label value (:label="0")
  2. Missing v-model binding for selection state
  3. 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)

Comment on lines +41 to +43
.demo-class {
height: 300px;
}
Copy link

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; } from examples/sites/demos/pc/app/dialog-box/dialog-width-composition-api.vue
  • Remove .demo-class { height: 300px; } from examples/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

Comment on lines +7 to +14
<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>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Improve radio groups implementation and accessibility

The current implementation of radio groups has several issues:

  1. Both radio groups have identical labels (:label="0")
  2. Each group contains only one option, which defeats the purpose of radio groups
  3. 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.

@zzcr zzcr merged commit e92d2ad into release-3.19.0 Nov 2, 2024
11 checks passed
@kagol kagol deleted the fix-dialog-box-1029 branch November 4, 2024 06:17
@coderabbitai coderabbitai bot mentioned this pull request Nov 4, 2024
13 tasks
zzcr pushed a commit that referenced this pull request Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants