-
Notifications
You must be signed in to change notification settings - Fork 354
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
fix: add block panel can't open #827
fix: add block panel can't open #827
Conversation
WalkthroughThe changes across various components focus on enhancing user interaction and refining event handling. Key modifications include the introduction of a new Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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 (
|
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
🧹 Outside diff range and nitpick comments (5)
packages/plugins/materials/src/meta/layout/src/Main.vue (2)
9-13
: LGTM! Consider a minor improvement for clarity.The change from
:rightPanelRef
to:rightPanelClassName
is a good approach to address the issue with the block panel. Using a class name instead of a ref provides more flexibility in styling and manipulation.For improved clarity, consider using an explicit string concatenation instead of a template literal:
- :rightPanelClassName="`.${rightPanelClassName}`" + :rightPanelClassName="'.' + rightPanelClassName"This makes it clearer that we're passing a CSS selector string.
17-17
: LGTM! Consider a minor adjustment for consistency.The addition of a new div element with a dynamic class binding for the right panel is a good approach. This change likely contributes to resolving the issue with the block panel not opening.
For consistency with the earlier change, consider using the same class name format:
- <div :class="rightPanelClassName"></div> + <div :class="'.' + rightPanelClassName"></div>This ensures that the class selector is consistent throughout the component.
packages/plugins/block/src/Main.vue (2)
92-92
: Improved event handling for editing blocks.The change from
@click
to@editBlock
is a good improvement. It provides better semantics and likely resolves the issue where the block panel couldn't open. This change ensures that the edit action is triggered only when intended, rather than on any click event.Consider adding error handling in the
editBlock
method to gracefully handle any potential errors during the block refresh or initialization process. For example:const editBlock = async (block) => { try { const isEdite = true if (isSaved()) { await refreshBlockData(block) useBlock().initBlock(block, {}, isEdite) useLayout().closePlugin() closePanel() const url = new URL(window.location) url.searchParams.delete('pageid') url.searchParams.set('blockid', block.id) window.history.pushState({}, '', url) } else { confirm({ message: '当前画布内容尚未保存,是否要继续切换?', exec: async () => { await refreshBlockData(block) useBlock().initBlock(block, {}, isEdite) useLayout().closePlugin() closePanel() } }) } } catch (error) { console.error('Error editing block:', error) // Handle the error appropriately, e.g., show an error message to the user } }
Line range hint
1-24
: Consider extracting block list rendering logic.The
<plugin-block-list>
component seems to handle a lot of functionality. To improve maintainability and reusability, consider extracting the block list rendering logic into a separate component. This would make the main component less complex and easier to manage.You could create a new component, for example,
BlockList.vue
, and move the relevant template and logic there:<!-- BlockList.vue --> <template> <plugin-block-list class="plugin-block-list" :data="blockList" :isBlockManage="true" :showBlockShot="true" :blockStyle="layout" default-icon-tip="查看区块" :externalBlock="externalBlock" @editBlock="editBlock" @iconClick="openSettingPanel" ></plugin-block-list> </template> <script> export default { props: ['blockList', 'layout', 'externalBlock'], methods: { editBlock(block) { this.$emit('editBlock', block) }, openSettingPanel(data) { this.$emit('openSettingPanel', data) } } } </script>Then, in your main component:
<template> <!-- ... other code ... --> <block-list :blockList="state.blockList" :layout="state.layout" :externalBlock="externalBlock" @editBlock="editBlock" @openSettingPanel="openSettingPanel" ></block-list> <!-- ... other code ... --> </template> <script> import BlockList from './BlockList.vue' export default { components: { // ... other components ... BlockList }, // ... rest of your component logic ... } </script>This refactoring would improve the overall structure and maintainability of your code.
Also applies to: 89-95
packages/common/component/PluginBlockList.vue (1)
266-268
: Implemented edit functionality for blocksThe
blockClick
method has been simplified, and a neweditBlock
method has been added. This change separates the concerns of clicking and editing blocks, improving the code's clarity and maintainability. TheeditBlock
method is also properly added to the returned object.Consider adding a comment to explain the purpose of the
editBlock
method and its parameters for better code documentation. For example:+ // Handle the editing of a block + // event: The triggering event + // item: The block item being edited + // index: The index of the block in the list const editBlock = ({ event, item, index }) => { if (props.isBlockManage) { state.activeIndex = index } emit('editBlock', item) // 点击区块并不打开设置面板 emit('iconClick', { event, item, index, isOpen: false }) }Also applies to: 270-277, 369-369
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
- packages/common/component/PluginBlockList.vue (8 hunks)
- packages/plugins/block/src/Main.vue (1 hunks)
- packages/plugins/materials/src/meta/block/src/BlockPanel.vue (2 hunks)
- packages/plugins/materials/src/meta/block/src/Main.vue (1 hunks)
- packages/plugins/materials/src/meta/layout/src/Main.vue (3 hunks)
🔇 Additional comments (15)
packages/plugins/materials/src/meta/block/src/Main.vue (2)
13-13
: LGTM, but verify impact on related components.The removal of
activeTabName
andrightPanelRef
props simplifies this component's interface. However, please ensure the following:
- Verify that the
BlockPanel
component doesn't rely on these props for its functionality.- Check if any parent components are still passing these props unnecessarily.
- Update component documentation to reflect this change in the component's API.
To verify the usage of these props in the
BlockPanel
component and potential parent components, run the following script:If these tests return results, it indicates that further adjustments may be needed in the related components.
Line range hint
1-24
: Provide more context on how this change addresses the PR objective.While this change simplifies the component, it's not immediately clear how it contributes to fixing the issue of the block panel not opening. Could you please provide more context on:
- How this change relates to the block panel opening issue?
- Are there other changes in different files that work together with this modification to solve the problem?
- Have you tested that the block panel now opens correctly after this change?
This additional information will help reviewers better understand the full scope and impact of the PR.
To help verify if this is the only change related to the block panel, you can run the following script:
This will show any other files that mention the block panel and have been changed in this PR, which might provide more context on the full solution.
✅ Verification successful
To accurately check for other changes related to the block panel, please run the following script:
Multiple related files have been modified.
The PR includes changes not only in
Main.vue
but also inBlockPanel.vue
,BlockList.vue
, andBlockGroup.vue
. This indicates a more comprehensive approach to addressing the block panel functionality. Please ensure that all these changes collectively resolve the issue of the block panel not opening and have been thoroughly tested.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for other changes related to the block panel echo "Checking for other changes related to the block panel:" git diff --name-only | xargs rg --type vue 'block-panel|BlockPanel'Length of output: 311
Script:
# #!/bin/bash # Description: Check for other changes related to the block panel echo "Checking for other changes related to the block panel:" git diff --name-only | xargs rg --glob "*.vue" 'block-panel|BlockPanel'Length of output: 1476
packages/plugins/materials/src/meta/layout/src/Main.vue (3)
28-29
: LGTM! Good use of a constant for the class name.The introduction of the
rightPanelClassName
constant is a good practice. It centralizes the definition of the class name, making it easier to maintain and update if needed in the future. The naming is clear and descriptive.
85-85
: LGTM! Necessary addition for template usage.The addition of
rightPanelClassName
to the returned object in the setup function is correct and necessary. This makes the constant available for use in the template, which is consistent with the Vue 3 Composition API pattern.
Line range hint
1-116
: Overall assessment: Changes look good and likely address the reported issue.The modifications made to this file appear to effectively address the PR objective of fixing the "add block panel can't open" issue. The shift from using a ref to a class name for the right panel provides more flexibility and could resolve any rendering or accessibility problems that were preventing the panel from opening.
Key points:
- The introduction of
rightPanelClassName
constant improves maintainability.- The consistent use of this class name throughout the component ensures proper styling and manipulation of the right panel.
- The changes are well-implemented and follow Vue 3 best practices.
While the changes look good, it would be beneficial to:
- Verify that these changes indeed resolve the issue with opening the block panel.
- Consider the minor suggestions for improved clarity and consistency in the template.
- Ensure that any related components or styles that might have depended on the previous implementation (using
rightPanelRef
) have been updated accordingly.To ensure the changes resolve the issue and don't introduce any regressions, please run the following verification steps:
These checks will help ensure that the changes have been applied consistently and don't conflict with existing styles or usage patterns.
packages/plugins/materials/src/meta/block/src/BlockPanel.vue (3)
9-9
: Verify the teleport changes and provide documentation.The teleport component has undergone two significant changes:
- The
:to
attribute now usesrightPanelClassName
instead ofrightPanelRef
.- A
defer
attribute has been added.These changes may affect the rendering behavior and targeting of the teleported content. Please ensure that:
- The
rightPanelClassName
correctly targets the intended destination element.- The
defer
attribute's impact on rendering timing is understood and intentional.Could you provide more context on why these changes were made and how they address the issue of the block panel not opening? Additionally, consider updating the component's documentation to reflect these changes and their implications.
38-45
: Props changes look good, consider adding validation.The changes to the props improve the component's flexibility and correspond to the template changes:
activeTabName
now has a default value, which is a good practice.- The new
rightPanelClassName
prop aligns with the teleport changes in the template.To further enhance the robustness of the component, consider adding prop validation:
props: { activeTabName: { type: String, default: '', validator: (value) => ['', 'tab1', 'tab2', ...].includes(value) // Add valid tab names }, rightPanelClassName: { type: String, default: '', validator: (value) => /^[a-zA-Z_][a-zA-Z0-9_-]*$/.test(value) || value === '' // Ensure valid CSS class name } }This addition would help catch potential issues early in development.
Line range hint
1-208
: Please clarify how these changes fix the block panel opening issue.The changes made to the component, particularly the teleport modifications and the addition of the
rightPanelClassName
prop, suggest an attempt to address targeting issues. However, it's not immediately clear how these changes solve the reported problem of the block panel being unable to open.Could you provide more context on:
- What was preventing the block panel from opening before these changes?
- How do the teleport modifications and the new
rightPanelClassName
prop resolve this issue?- Have you tested these changes to confirm that the block panel now opens correctly?
This information will help in understanding the full impact of the changes and ensure that the fix is comprehensive.
packages/plugins/block/src/Main.vue (1)
Line range hint
1-605
: Overall assessment: Approved with suggestions for improvementThe change from
@click
to@editBlock
on the<plugin-block-list>
component effectively addresses the reported issue of the block panel not opening. This modification improves event handling specificity and aligns well with the component's intended behavior.While the overall structure of the component is well-organized, there are opportunities for further enhancement:
- Consider adding error handling in the
editBlock
method to gracefully manage potential issues during block refresh or initialization.- To improve maintainability and reusability, consider extracting the block list rendering logic into a separate component.
These suggestions aim to enhance the robustness and maintainability of the code without introducing significant changes to the current implementation.
packages/common/component/PluginBlockList.vue (6)
3-3
: Improved rendering condition for block listThe condition for rendering the block list has been updated to include
showAddButton
. This change allows the list to be displayed even when there are no data items, as long as the add button is shown.
13-13
: Updated event handler for block clickThe
mousedown
event handler has been changed to callblockClick
instead of directly emitting a click event. This change allows for more flexibility in handling block clicks.
75-77
: Added edit functionality for blocksA new list item has been added to allow editing of blocks. This enhances the functionality of the component by providing users with the ability to edit existing blocks.
136-138
: Updated rendering conditions for add button and search-empty componentThe conditions for rendering the add button and the search-empty component have been updated to consider the
showAddButton
prop. This change improves the component's flexibility and user experience.Also applies to: 153-153
232-232
: Added editBlock event to emits arrayThe
editBlock
event has been added to the emits array, allowing the component to communicate edit actions to its parent component.
Line range hint
1-753
: Overall assessment: Improved functionality and flexibilityThe changes made to the PluginBlockList component enhance its functionality and flexibility. Key improvements include:
- Added edit functionality for blocks
- Updated rendering conditions for better handling of edge cases
- Simplified block click handling
These changes improve the component's usability and maintainability without introducing any apparent issues. The code structure remains consistent with the existing codebase, and the new features are well-integrated.
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.
* fix: add block panel can't open * fix: blockgroup select * fix: support vue3.5 below version
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
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
editBlock
event for clearer editing actions.Improvements
editBlock
event for better clarity.Refactor