-
Notifications
You must be signed in to change notification settings - Fork 326
fix(dropdown): modify the responsive adaptation of the drop-down arrow in the mobile first template #3614
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
…w in the mobile first template
WalkthroughThe changes introduce breakpoint awareness to the dropdown's renderless logic by utilizing a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 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/dropdown/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. packages/vue/src/dropdown/src/mobile-first.vueOops! 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. Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
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:
SupportNeed 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)
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/renderless/src/dropdown/vue.ts
(1 hunks)packages/vue/src/dropdown/src/mobile-first.vue
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/renderless/src/dropdown/vue.ts (1)
packages/renderless/types/dropdown.type.ts (3)
IDropdownRenderlessParamUtils
(65-65)IDropdownApi
(35-57)IDropdownState
(19-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (4)
packages/renderless/src/dropdown/vue.ts (2)
48-48
: LGTM! Proper parameter addition.The
useBreakpoint
utility is correctly added to the destructured parameters following the established pattern.
51-51
: LGTM! Correct composable usage.The
useBreakpoint()
composable is properly called and thecurrent
value is correctly destructured.packages/vue/src/dropdown/src/mobile-first.vue (2)
126-130
: Excellent improvement to icon rendering logic.The conditional rendering based on
state.current
is much more efficient than the previous approach of rendering both icons with visibility classes. The logic correctly shows:
- Chevron icon for larger screens (non-default breakpoints)
- Arrow icon for mobile/default breakpoint
This change improves both performance and maintainability.
166-167
: Minor formatting improvement.The indentation adjustment improves readability of the ternary operator without changing the logic.
const api = {} as IDropdownApi | ||
const { current } = useBreakpoint() | ||
const state: IDropdownState = reactive({ | ||
current, |
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.
💡 Verification agent
🧩 Analysis chain
Update the IDropdownState interface to include the current property.
The current
property is added to the reactive state but is not defined in the IDropdownState
interface. This may cause TypeScript compilation issues.
Please verify that the interface needs to be updated by checking the type definition file:
If the current
property is missing from the interface, please add it:
export interface IDropdownState {
visible: boolean
timeout: null | NodeJS.Timeout
focusing: false
menuItems: NodeListOf<HTMLElement> | undefined | null | []
menuItemsArray: HTMLElement[] | null
triggerElm: HTMLElement | null
dropdownElm: HTMLElement | null
listId: string
showIcon: boolean
showSelfIcon: boolean
designConfig: IDropdownRenderlessParamUtils['designConfig']
trigger: 'click' | 'hover'
visibleIsBoolean: boolean
+ current: string
}
🏁 Script executed:
#!/bin/bash
# Check if the IDropdownState interface includes the current property
rg -A 20 "interface IDropdownState" packages/renderless/types/dropdown.type.ts
Length of output: 692
Add current
to the IDropdownState
interface
The current
property is being initialized in the reactive state (packages/renderless/src/dropdown/vue.ts) but is missing from the IDropdownState
definition, which will lead to TypeScript errors.
Locations to update:
- packages/renderless/types/dropdown.type.ts
Suggested diff:
export interface IDropdownState {
visible: boolean
timeout: null | NodeJS.Timeout
focusing: false
menuItems: NodeListOf<HTMLElement> | undefined | null | []
menuItemsArray: HTMLElement[] | null
triggerElm: HTMLElement | null
dropdownElm: HTMLElement | null
listId: string
showIcon: boolean
showSelfIcon: boolean
designConfig: IDropdownRenderlessParamUtils['designConfig']
trigger: 'click' | 'hover'
visibleIsBoolean: boolean
+ current: string
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
current, | |
// File: packages/renderless/types/dropdown.type.ts | |
export interface IDropdownState { | |
visible: boolean | |
timeout: null | NodeJS.Timeout | |
focusing: false | |
menuItems: NodeListOf<HTMLElement> | undefined | null | [] | |
menuItemsArray: HTMLElement[] | null | |
triggerElm: HTMLElement | null | |
dropdownElm: HTMLElement | null | |
listId: string | |
showIcon: boolean | |
showSelfIcon: boolean | |
designConfig: IDropdownRenderlessParamUtils['designConfig'] | |
trigger: 'click' | 'hover' | |
visibleIsBoolean: boolean | |
current: string | |
} |
🤖 Prompt for AI Agents
In packages/renderless/types/dropdown.type.ts near the definition of the
IDropdownState interface, add the missing property 'current' with the
appropriate type to match its initialization in
packages/renderless/src/dropdown/vue.ts line 53. This will align the interface
with the reactive state and prevent TypeScript errors.
修改 dropdown的多端模板,根据响应式切换后面的下拉图标的显示
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
Style