opentiny / tiny-vue

TinyVue is an enterprise-class UI component library of OpenTiny community, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.
https://opentiny.design/tiny-vue
MIT License
1.67k stars 266 forks source link

fix(calendar-view): [calendar-view] Fix bug with invalid calendar hei… #2520

Open Youyou-smiles opened 2 days ago

Youyou-smiles commented 2 days ago

…ght value

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

coderabbitai[bot] commented 2 days ago

Walkthrough

The changes in this pull request focus on enhancing the calendar-view component across several files. The height property type has been modified to allow both string and number values, improving flexibility. Additionally, the CSS for the calendar view has been updated to include an overflow: auto; property, enabling scrolling for overflowing content. The Vue component's template has also been adjusted to conditionally apply styles based on the height property type, streamlining the rendering logic.

Changes

File Path Change Summary
examples/sites/demos/apis/calendar-view.js Updated height property type from string to string | number.
packages/theme/src/calendar-view/index.less Added overflow: auto; to the main calendar view class for scrolling when content overflows.
packages/vue/src/calendar-view/src/index.ts Changed height property type in calendarViewProps from String to [String, Number].
packages/vue/src/calendar-view/src/pc.vue Adjusted template to conditionally apply height styles based on height prop type; cleaned up rendering logic.

Possibly related PRs

Suggested reviewers

🐇 In the garden where the calendars grow,
A height change here, a style change there, oh!
With overflow set, the content can scroll,
Flexibility blooms, making it all whole.
Hopping through code, we make it just right,
Our calendar's ready, oh what a delight! 🌼


📜 Recent review details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
📥 Commits Reviewing files that changed from the base of the PR and between 6abbcdf023a1eb76bccd16d44e995dbdc9536640 and 68f1db2d591c111be7e580bc2804c9b6ac3de2d9.
📒 Files selected for processing (1) * `examples/sites/demos/pc/app/calendar-view/calendar-disabled-day.spec.ts` (1 hunks)
🔇 Additional comments (2)
examples/sites/demos/pc/app/calendar-view/calendar-disabled-day.spec.ts (2) `9-11`: **LGTM: Assertions are correctly maintained** The assertions checking for disabled states and date classes remain appropriate and aligned with the component's expected behavior. --- `6-8`: **Verify the robustness of the new day selectors** While the selector changes appear to fix the immediate issue, using nth-based selectors might be fragile if the calendar's DOM structure changes. Consider using more robust selectors that are less dependent on element order. Here's a script to verify the uniqueness and stability of the day selectors: Consider refactoring to use more specific selectors: ```diff - const day10 = page.getByText('10').nth(1) - const day14 = page.getByText('14').nth(1) - const day15 = page.getByText('15').nth(2) + // Add data-testid attributes to calendar days in the component + const day10 = page.getByTestId('calendar-day-10') + const day14 = page.getByTestId('calendar-day-14') + const day15 = page.getByTestId('calendar-day-15') ```
✅ Verification successful Let me gather more information about the calendar day rendering and test patterns to better assess the situation. --- Let me check the calendar component implementation to understand the day rendering structure better. --- Let me try one final check focusing on the specific calendar-disabled-day implementation and its test. --- Based on the gathered information, I can now provide a final response: **The nth-based selectors are appropriate for this calendar implementation** The calendar component's implementation and test patterns reveal that: 1. The component uses a disabled function that affects all dates before the 15th, which explains why we need specific nth selectors for dates 10, 14, and 15 2. Other calendar tests in the same directory also consistently use nth selectors for date selection 3. The selector changes align with the component's rendering logic where: - Dates before 15 are disabled (matching the disabled function implementation) - Multiple instances of the same date can appear due to the calendar grid structure The nth-based selectors are currently the most reliable way to target specific dates in this calendar implementation, as: - The dates appear multiple times due to the calendar's month-view structure - The component doesn't expose more specific attributes for testing - Other calendar tests in the codebase follow the same pattern
🏁 Scripts executed The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Check for potential selector ambiguity in calendar-view tests # Search for similar test files that might be affected by this change echo "Checking for related test files..." rg -l "getByText\(('|\")(?:10|14|15)('|\")\)\.nth\(" --type ts # Look for the calendar day rendering logic echo "Checking calendar day rendering implementation..." ast-grep --pattern 'render() { $$$ return ( $$$
$$$ {/* Look for day rendering logic */} $$$
) }' ``` Length of output: 604 --- Script: ```shell #!/bin/bash # Check the implementation and usage patterns in related files # Look at the calendar-disabled-day test implementation echo "Calendar disabled day test implementation:" cat examples/sites/demos/pc/app/calendar-view/calendar-disabled-day.spec.ts # Check other test files using similar selectors echo -e "\nRelated test implementations:" rg -A 5 "getByText\(('|\")(?:10|14|15)('|\")\)\.nth\(" examples/sites/demos/pc/app/popeditor/condition-form.spec.ts examples/sites/demos/pc/app/date-picker/default-value.spec.ts # Look for calendar day rendering patterns echo -e "\nCalendar day rendering patterns:" rg -A 10 "class=\"tiny-calendar-date\"" --type-add 'vue:*.{vue,tsx}' --type vue ``` Length of output: 2186 --- Script: ```shell #!/bin/bash # Search for calendar component implementation echo "Searching for calendar component files:" fd -e vue -e tsx calendar # Check the implementation of calendar days echo -e "\nChecking calendar day implementation:" rg -A 10 "class.*?(?:date|calendar-date|calendar-cell)" --type vue --type tsx # Look for any data-testid usage in the codebase echo -e "\nChecking existing data-testid patterns:" rg "data-testid" --type vue --type tsx --type ts ``` Length of output: 2612 --- Script: ```shell #!/bin/bash # Check the specific calendar disabled day implementation and test echo "Calendar disabled day component:" cat examples/sites/demos/pc/app/calendar-view/calendar-disabled-day.vue echo -e "\nChecking for similar nth selector patterns in other calendar tests:" rg "nth\(" examples/sites/demos/pc/app/calendar-view/*.spec.ts # Check if there are any existing test utilities or helper functions echo -e "\nChecking for test utilities:" fd -e ts "test-utils" "helpers" ``` Length of output: 3274

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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.