-
Notifications
You must be signed in to change notification settings - Fork 309
fix(cascader): [cascader,select] add the changeCompat attribute to the component #2934
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
WalkthroughThis pull request updates the cascader component in both renderless and Vue implementations. It introduces a new exported function Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Component
participant watchValue
participant watchCheckedValue
participant Emitter
User->>Component: Initiates value change
Component->>watchValue: Call with new value
watchValue-->>Component: Update state (checkedValue, userChangeValue)
Component->>watchCheckedValue: Invoke with new value and props
alt User-initiated change (state.userChangeValue true)
watchCheckedValue->>Emitter: Emit update:modelValue & change events
watchCheckedValue->>Component: Reset userChangeValue flag
else Programmatic change
watchCheckedValue->>Emitter: Emit update:modelValue & change events
end
Possibly related PRs
Suggested labels
Suggested reviewers
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/cascader/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/cascader/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/cascader/src/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.
✨ Finishing Touches
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? 🪧 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 (
|
Walkthrough此PR为cascader组件添加了一个新的 Changes
|
WalkthroughThis PR adds a new Changes
|
[e2e-test-warn] The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug". Please make sure you've read our contributing guide |
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
🧹 Nitpick comments (2)
packages/vue/src/cascader/src/index.ts (1)
104-107
: Add JSDoc documentation for the changeCompat prop.While the prop is properly typed, adding documentation would help other developers understand its purpose and usage.
Add documentation above the prop:
+ /** + * When true, maintains compatibility with older behavior for change events. + * @default false + */ changeCompat: { type: Boolean, default: false }packages/renderless/src/cascader/index.ts (1)
85-93
: Consider usingnextTick
instead ofsetTimeout
.The function correctly handles user-initiated value changes. However, using
setTimeout
for computing present content might cause a flash of content. Consider using Vue'snextTick
for a more reliable update timing.- setTimeout(api.computePresentContent) + nextTick(api.computePresentContent)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/renderless/src/cascader/index.ts
(3 hunks)packages/renderless/src/cascader/vue.ts
(3 hunks)packages/vue/src/cascader/src/index.ts
(1 hunks)packages/vue/src/cascader/src/mobile-first.vue
(2 hunks)packages/vue/src/cascader/src/pc.vue
(1 hunks)packages/vue/src/option/src/pc.vue
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: PR Unit Test
- GitHub Check: PR E2E Test (pnpm test:e2e3)
🔇 Additional comments (6)
packages/vue/src/option/src/pc.vue (1)
20-20
: Great accessibility improvement!Adding the title attribute enhances the user experience by providing tooltips on hover, especially useful for truncated or long labels.
packages/vue/src/cascader/src/mobile-first.vue (1)
95-96
:❓ Verification inconclusive
Verify changeCompat event emission.
The changeCompat event is added to emits but there's no visible implementation emitting this event. Ensure the event is properly emitted where needed.
🏁 Script executed:
#!/bin/bash # Search for changeCompat event emissions rg -l "emit.*changeCompat" .Length of output: 30
ACTION REQUIRED: Verify changeCompat Event Emission
Our repository search (using
rg -l "emit.*changeCompat"
) did not reveal any instances where thechangeCompat
event is actually emitted. Please verify that this event is correctly triggered in the component's logic where applicable. If the omission is intentional, consider adding a brief comment to clarify why the event remains un-emitted.packages/renderless/src/cascader/vue.ts (2)
136-137
: LGTM!The addition of
userChangeValue
state property is well-designed to track user-initiated value changes, which is essential for the newchangeCompat
functionality.
192-192
: LGTM!The function signature update correctly includes the
props
parameter, which is necessary for accessing thechangeCompat
property.packages/renderless/src/cascader/index.ts (2)
84-84
: LGTM!The comment clearly explains the function's purpose and behavior regarding user-initiated value changes.
128-139
: LGTM!The event emission logic is well-implemented:
- User-initiated changes respect the
changeCompat
flag.- Non-user-initiated changes (clicks, deletes) maintain backward compatibility.
- The state is properly reset after handling user-initiated changes.
'blank', | ||
'changeCompat' |
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.
🛠️ Refactor suggestion
Maintain consistency with mobile-first component.
The mobile-first component includes 'changeCompat' in its emits array, but it's missing here. Consider adding it to maintain consistency across components.
Add the event to emits:
emits: [
'update:modelValue',
'change',
'visible-change',
'focus',
'blur',
'expand-change',
'active-item-change',
'remove-tag',
- 'created'
+ 'created',
+ 'changeCompat'
],
📝 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.
'blank', | |
'changeCompat' | |
emits: [ | |
'update:modelValue', | |
'change', | |
'visible-change', | |
'focus', | |
'blur', | |
'expand-change', | |
'active-item-change', | |
'remove-tag', | |
'created', | |
'changeCompat' | |
], |
PR
为cascader组件添加changeCompat属性
为option 组件添加默认的title属性
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