-
Notifications
You must be signed in to change notification settings - Fork 333
fix(picker): [date-picker]enhance the compatibility of the date picker on mobile and PC, add isPCMode parameter to control the display logic #3336
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
Conversation
…nd PC, add isPCMode parameter to control the display logic
WalkthroughThis update introduces an Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant PickerComponent
participant API
User->>PickerComponent: Focuses input
PickerComponent->>API: handleFocus({ ..., isPCMode })
API->>PickerComponent: Determines picker type
alt isPCMode true or not mobile
PickerComponent->>PickerComponent: Show PC-style picker
else
PickerComponent->>PickerComponent: Show mobile picker
end
Poem
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
packages/renderless/src/picker/index.tsOops! 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: 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. packages/renderless/src/picker/vue.tsOops! 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: 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. ✨ Finishing Touches
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. 🪧 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 (
|
WalkthroughThis PR enhances the compatibility of the date picker for both mobile and PC platforms by introducing an Changes
|
| ({ api, vm, dispatch, emit, props, state, nextTick, isPCMode }) => | ||
| (value) => { | ||
| if (props.readonly || state.pickerDisabled || state.isMobileScreen) return | ||
| if (props.readonly || state.pickerDisabled || (state.isMobileScreen && !isPCMode)) return |
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.
Ensure that the isPCMode parameter is correctly passed and utilized in all relevant functions to avoid potential logic errors in determining picker visibility.
| const api = {} as IPickerApi | ||
| const { reactive, computed, watch, onBeforeUnmount, inject, markRaw, onMounted } = hooks | ||
| const { vm, service, parent, useBreakpoint } = vnode | ||
| const { vm, service, parent, useBreakpoint, isPCMode } = vnode |
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.
Verify that isPCMode is consistently integrated into the API initialization to prevent any discrepancies in behavior across different devices.
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: 0
🧹 Nitpick comments (1)
packages/renderless/src/picker/index.ts (1)
1073-1075: Consider removing unnecessary whitespaceThere are extra blank lines that don't affect functionality but could be removed for consistency with the rest of the codebase.
state.pickerVisible = state.picker.state.visible = visible - api.emitInput(date, visible) - state.date = date
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/renderless/src/picker/index.ts(3 hunks)packages/renderless/src/picker/vue.ts(4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/renderless/src/picker/vue.ts (1)
packages/renderless/src/picker/index.ts (2)
handleFocus(942-968)watchPickerVisible(66-93)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (9)
packages/renderless/src/picker/vue.ts (5)
179-179: Function signature updated to include isPCMode parameterThe
initApifunction now includes anisPCModeparameter, which will help control the picker's display behavior on mobile vs PC screens. This is aligned with the PR's objective of enhancing component compatibility across platforms.
193-193: Properly passing isPCMode to handleFocusThe
isPCModeparameter is correctly forwarded to thehandleFocusmethod, ensuring the mode preference is considered when the picker receives focus.
216-216: Properly passing isPCMode to watchPickerVisibleThe
isPCModeparameter is correctly forwarded to thewatchPickerVisiblemethod, which will allow conditional picker visibility based on the mode preference.
309-310: Extracting isPCMode from vnodeThe
isPCModevalue is correctly extracted from thevnodeobject, making it available to the component's rendering logic.
316-316: Passing isPCMode to initApiThe
isPCModeparameter is properly passed to theinitApifunction, ensuring the mode preference propagates through the component's API initialization.packages/renderless/src/picker/index.ts (4)
66-69: Updated watchPickerVisible to honor isPCMode parameterThe
watchPickerVisiblefunction now properly considers theisPCModeflag when determining if the picker should be shown on mobile screens. This change enables consistent picker behavior across platforms when requested.
942-956: Enhanced handleFocus with isPCMode condition and improved commentsThe
handleFocusfunction now properly uses theisPCModeparameter to determine the picker display behavior on mobile screens. The added comments clearly explain the conditional logic, improving code readability and maintainability.
957-964: Improved comments for mobile date and time component conditionsThe added comments clearly explain the different conditions for displaying date and time mobile components, which improves code readability.
1067-1067: Minor code formatting improvementThe code formatting has been improved for better readability.
fix(picker): 增强日期选择器在移动端和PC端的兼容性,添加isPCMode参数以控制显示逻辑
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
Bug Fixes