Skip to content

fix(date-picker):fix the init panel width and month name #3466

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

Merged
merged 1 commit into from
Jun 4, 2025

Conversation

discreted66
Copy link
Collaborator

@discreted66 discreted66 commented May 29, 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?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Style

    • Increased the default width of the DatePanel component for improved visibility.
  • Refactor

    • Updated the method for generating month label keys in the month table component to enhance localization consistency.
  • Tests

    • Adjusted month label selectors in date picker tests to use numeric month formats with a space and the Chinese character for month.
    • Improved test element targeting for month range selection to ensure accurate interaction.

Copy link

coderabbitai bot commented May 29, 2025

"""

Walkthrough

The changes update the default width of the DatePanel component by adjusting a CSS variable and modify the localization key generation for month names in the month table component, switching from a lookup-based approach to a direct numeric suffix format. Corresponding test cases were updated to reflect the new month label formats and element targeting.

Changes

Files Change Summary
packages/theme/src/date-panel/vars.less Increased the DatePanel width from 284px to 360px by updating the CSS variable.
packages/vue/src/month-table/src/pc.vue Changed month label localization keys from a lookup to a direct numeric suffix template string.
examples/sites/demos/pc/app/date-picker/basic-usage.spec.ts Updated month cell selectors from Chinese month names to numeric month representations with suffix.
examples/sites/demos/pc/app/date-picker/date-range.spec.ts,
examples/sites/demos/pc/app/date-panel/basic-usage.spec.ts,
examples/sites/demos/pc/app/date-panel/custom-week.spec.ts,
examples/sites/demos/pc/app/date-panel/disabled-date.spec.ts,
examples/sites/demos/pc/app/date-panel/event.spec.ts,
examples/sites/demos/pc/app/date-panel/format.spec.ts,
examples/sites/demos/pc/app/date-panel/readonly.spec.ts,
examples/sites/demos/pc/app/date-panel/unlink-panels.spec.ts Updated month selectors and text labels from Chinese month names to numeric month formats with a space and "月" suffix; adjusted element targeting (e.g., added .first() in one case). No other logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MonthTableComponent
    participant LocalizationSystem

    User->>MonthTableComponent: Render month table
    MonthTableComponent->>LocalizationSystem: Request label for `ui.datepicker.month${cell.text + 1}`
    LocalizationSystem-->>MonthTableComponent: Return localized month name
    MonthTableComponent-->>User: Display month name
Loading

Possibly related PRs

Suggested reviewers

  • zzcr

Poem

A rabbit hopped by the date panel’s side,
“Let’s make it wider!” the bunny replied.
Months now appear with numbers so neat,
Localization’s new trick is quite the treat.
With every hop and every tweak,
The calendar grows more user-unique!
🐇✨
"""

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

examples/sites/demos/pc/app/date-panel/basic-usage.spec.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/demos/pc/app/date-panel/custom-week.spec.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

examples/sites/demos/pc/app/date-panel/disabled-date.spec.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-vue".

(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-vue@latest --save-dev

The plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 7 others

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce01c5b and 4a8479b.

📒 Files selected for processing (11)
  • examples/sites/demos/pc/app/date-panel/basic-usage.spec.ts (2 hunks)
  • examples/sites/demos/pc/app/date-panel/custom-week.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/date-panel/disabled-date.spec.ts (2 hunks)
  • examples/sites/demos/pc/app/date-panel/event.spec.ts (2 hunks)
  • examples/sites/demos/pc/app/date-panel/format.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/date-panel/readonly.spec.ts (2 hunks)
  • examples/sites/demos/pc/app/date-panel/unlink-panels.spec.ts (2 hunks)
  • examples/sites/demos/pc/app/date-picker/basic-usage.spec.ts (1 hunks)
  • examples/sites/demos/pc/app/date-picker/date-range.spec.ts (1 hunks)
  • packages/theme/src/date-panel/vars.less (1 hunks)
  • packages/vue/src/month-table/src/pc.vue (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • packages/theme/src/date-panel/vars.less
  • examples/sites/demos/pc/app/date-picker/basic-usage.spec.ts
🚧 Files skipped from review as they are similar to previous changes (9)
  • examples/sites/demos/pc/app/date-panel/readonly.spec.ts
  • examples/sites/demos/pc/app/date-panel/custom-week.spec.ts
  • packages/vue/src/month-table/src/pc.vue
  • examples/sites/demos/pc/app/date-panel/unlink-panels.spec.ts
  • examples/sites/demos/pc/app/date-panel/format.spec.ts
  • examples/sites/demos/pc/app/date-panel/basic-usage.spec.ts
  • examples/sites/demos/pc/app/date-panel/disabled-date.spec.ts
  • examples/sites/demos/pc/app/date-picker/date-range.spec.ts
  • examples/sites/demos/pc/app/date-panel/event.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@github-actions github-actions bot added the bug Something isn't working label May 29, 2025
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cfb7481 and 1f1370a.

📒 Files selected for processing (2)
  • packages/theme/src/date-panel/vars.less (1 hunks)
  • packages/vue/src/month-table/src/pc.vue (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (1)
packages/theme/src/date-panel/vars.less (1)

24-24: LGTM! Width increase addresses the narrow panel issue.

The increase from the implied previous width to 360px provides better usability for the date picker panel, addressing the stated issue of the panel being too narrow.

@@ -15,7 +15,7 @@
<tr v-for="(row, key) in state.rows" :key="key">
<td v-for="(cell, key) in row" :class="getCellStyle(cell)" :key="key">
<div>
<a class="cell" v-text="t('ui.datepicker.months.' + state.months[cell.text])"></a>
<a class="cell" v-text="t(`ui.datepicker.month${cell.text + 1}`)"></a>
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify that the new localization keys are properly defined.

The change from array-based lookup to direct numeric suffix format (ui.datepicker.month${cell.text + 1}) looks good for providing full month names instead of abbreviated forms. However, please ensure that:

  1. The new localization keys (ui.datepicker.month1, ui.datepicker.month2, etc.) are defined in all language files
  2. The cell.text value is guaranteed to be a number in the range 0-11
  3. This change doesn't break existing translations or components that might depend on the previous key format

🏁 Script executed:

#!/bin/bash
# Description: Verify the new localization keys exist and check for potential breaking changes

# Test: Search for the new localization key pattern in language files
rg -A 2 -B 2 "ui\.datepicker\.month[0-9]" --type json --type js --type ts

# Test: Check if the old key pattern is still used elsewhere
rg "ui\.datepicker\.months\." --type vue --type js --type ts

# Test: Find where cell.text is defined to verify it's always numeric
ast-grep --pattern 'cell.text'

Length of output: 1360


🏁 Script executed:

#!/bin/bash
# Search all locale files for the new month keys (month1–month12)
rg -n "ui\\.datepicker\\.month[0-9]+" -g "*.{json,js,ts,yml,yaml,vue}"

# Search for any remaining uses of the old key pattern
rg -n "ui\\.datepicker\\.months\\." -g "*.{vue,js,ts}"

# Inspect how cell.text is populated in the month-table logic
sed -n '50,150p' packages/renderless/src/month-table/index.ts

Length of output: 2727


Define new month translation keys in all locale files

The switch to t(\ui.datepicker.month${cell.text + 1}`) requires new keys (ui.datepicker.month1throughui.datepicker.month12`), but none are defined in the current locale files. To prevent missing-translation errors:

  • Add ui.datepicker.month1ui.datepicker.month12 entries to each language’s resource file, corresponding to full month names.
  • Confirm that cell.text (0–11) always yields valid keys once incremented.
  • Review the existing monthNames utility in packages/utils/src/date-util/index.ts (line 37) which still uses the old ui.datepicker.months.{month} pattern—either update it to use the new numeric keys or clean up the legacy keys if they’re no longer needed.
🤖 Prompt for AI Agents
In packages/vue/src/month-table/src/pc.vue at line 18, the localization key
format was changed to use numeric suffixes (ui.datepicker.month1 to month12). To
fix this, add these new keys with full month names to all locale resource files
to avoid missing translations. Verify that cell.text is always a number from 0
to 11 so that adding 1 produces valid keys. Also, update or remove the old
monthNames utility in packages/utils/src/date-util/index.ts around line 37 to
align with the new key format and prevent inconsistencies.

zzcr
zzcr previously approved these changes Jun 2, 2025
@discreted66 discreted66 force-pushed the panel0529 branch 3 times, most recently from ce01c5b to 4a8479b Compare June 3, 2025 07:57
@zzcr zzcr merged commit e3c5559 into opentiny:dev Jun 4, 2025
5 checks passed
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