-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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: when a table switches paging, no form parameters will be carried #4607
Conversation
|
WalkthroughThe pull request encompasses modifications to several Vue component files, primarily involving the removal of the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🔇 Additional comments (4)
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: 3
🧹 Outside diff range and nitpick comments (4)
playground/src/views/examples/vxe-table/basic.vue (2)
Line range hint
1-31
: Approve unchanged code and suggest improvementThe existing code structure and implementation look good. The component follows Vue 3 composition API practices and provides a clean setup for the VxeGrid component with various configuration options.
As a potential improvement, consider extracting the grid configuration (columns, data, etc.) into a separate file or function. This would enhance code organization and make it easier to manage complex grid setups in larger applications.
Here's an example of how you could refactor the grid configuration:
// gridConfig.ts import { VxeGridProps } from '#/adapter'; import { MOCK_TABLE_DATA } from './table-data'; export const getGridOptions = (): VxeGridProps<RowType> => ({ columns: [ { title: '序号', type: 'seq', width: 50 }, { field: 'name', title: 'Name' }, { field: 'age', sortable: true, title: 'Age' }, { field: 'nickname', title: 'Nickname' }, { field: 'role', title: 'Role' }, { field: 'address', showOverflow: true, title: 'Address' }, ], data: MOCK_TABLE_DATA, pagerConfig: { enabled: false, }, sortConfig: { multiple: true, }, }); // In your component import { getGridOptions } from './gridConfig'; const gridOptions = getGridOptions();This refactoring would make the main component file cleaner and more focused on component-specific logic.
Also applies to: 35-105
Line range hint
1-105
: Summary of review findings
- The main change (disabling pagination) seems to contradict the PR objectives. Clarification is needed on how this addresses the issue of retaining form parameters during paging.
- The existing code structure is good and follows Vue 3 best practices.
- A suggestion for improving code organization by extracting grid configuration has been provided.
Next steps:
- Address the discrepancy between the PR objectives and the implemented changes.
- Consider the suggested refactoring for improved code organization.
- If the pagination disabling is not the intended solution, implement a fix that retains form parameters during page switches while keeping pagination enabled.
Please update the PR description or code to align with the intended objectives and respond to the review comments.
packages/effects/plugins/src/vxe-table/extends.ts (2)
36-36
: Remove the unused parameter_formValues
inwrapperFn
.The parameter
_formValues
in thewrapperFn
function is declared but not used. Removing it will clean up the code and prevent potential confusion.Apply this diff to remove the unused parameter:
-const wrapperFn = async (params: any, _formValues: any, ...args: any[]) => { +const wrapperFn = async (params: any, ...args: any[]) => {
31-33
: Handle cases whereconfigFn
might be undefined or not a function.If
configFn
is not a function or is undefined, the current code silently returns without any feedback. Consider adding a warning or error message to aid in debugging and to inform developers that a proxy function is missing or incorrectly defined.Example:
if (!isFunction(configFn)) { + console.warn(`The proxy function for key "${key}" is not defined or is not a function.`); return options; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (9)
- packages/effects/layouts/src/widgets/preferences/blocks/layout/copyright.vue (0 hunks)
- packages/effects/layouts/src/widgets/preferences/blocks/layout/footer.vue (0 hunks)
- packages/effects/layouts/src/widgets/preferences/blocks/layout/header.vue (0 hunks)
- packages/effects/layouts/src/widgets/preferences/blocks/layout/sidebar.vue (0 hunks)
- packages/effects/plugins/src/vxe-table/extends.ts (1 hunks)
- packages/effects/plugins/src/vxe-table/use-vxe-grid.vue (5 hunks)
- playground/src/views/examples/vxe-table/basic.vue (1 hunks)
- playground/src/views/examples/vxe-table/fixed.vue (0 hunks)
- playground/src/views/examples/vxe-table/form.vue (4 hunks)
💤 Files with no reviewable changes (5)
- packages/effects/layouts/src/widgets/preferences/blocks/layout/copyright.vue
- packages/effects/layouts/src/widgets/preferences/blocks/layout/footer.vue
- packages/effects/layouts/src/widgets/preferences/blocks/layout/header.vue
- packages/effects/layouts/src/widgets/preferences/blocks/layout/sidebar.vue
- playground/src/views/examples/vxe-table/fixed.vue
🧰 Additional context used
🔇 Additional comments (12)
playground/src/views/examples/vxe-table/form.vue (4)
6-6
: LGTM: Import changes align with component updates.The addition of
message
import and removal ofButton
import are consistent with the changes in component functionality.
63-64
: Verify the necessity ofshowCollapseButton
and translate the comment.The addition of
showCollapseButton: true
seems to contradict the removal of collapse button functionality mentioned in the PR summary. Please verify if this property is still needed.Also, consider translating the Chinese comment to English for consistency:
- // 控制表单是否显示折叠按钮 + // Control whether the form displays a collapse button
104-104
: LGTM: Template simplified.The simplification of the template by rendering the
Grid
component without additional props or surrounding elements is a clean approach. It aligns with the removal of the toggle collapse functionality mentioned in the PR summary.
Line range hint
1-106
: Verify alignment with PR objectives and update PR description if needed.While the changes made improve certain aspects of the component, they don't seem to directly address the main PR objective of "fix: when a table switches paging, no form parameters will be carried". The visible changes focus on:
- Updating imports
- Adding a
showCollapseButton
option- Modifying the
query
function signature- Simplifying the template
Please verify if these changes indeed solve the described issue. If so, consider updating the PR description to better reflect the actual changes made. If not, ensure that the fix for the paging issue is included in this PR.
Additionally, some changes (like adding
showCollapseButton
) seem to contradict the PR summary mentioning the removal of collapse functionality. Please clarify these inconsistencies.playground/src/views/examples/vxe-table/basic.vue (1)
32-34
: Verify alignment with PR objectivesThe addition of
pagerConfig: { enabled: false }
disables pagination for the grid component. This change seems to contradict the PR objectives, which mention fixing an issue with form parameters when switching table paging. Disabling pagination entirely doesn't address the described issue of retaining form parameters during paging transitions.Please clarify if this change is intentional and how it addresses the stated objective of the PR. If the intention is to fix form parameter retention during paging, consider implementing a solution that keeps pagination enabled while ensuring form parameters are carried over during page switches.
To help verify the impact of this change, you can run the following script:
This script will help identify other instances of
pagerConfig
usage and potential form-related code near table components, which might be relevant to the PR objectives.packages/effects/plugins/src/vxe-table/extends.ts (2)
5-5
: Verify the source ofisFunction
to ensure consistency.Currently,
isFunction
is imported from@vben/utils
. Ensure that this utility behaves as expected and is consistent with other parts of the codebase. If other utility functions are imported from a different library (e.g., lodash), consider standardizing the import source.
36-40
: Ensure the function signature matches the expected parameters ofconfigFn
.Wrapping
configFn
withwrapperFn
changes the function signature by introducingformValues
as the second argument. Verify that all originalconfigFn
functions acceptformValues
as the second parameter. If they do not, this could lead to unexpected behavior or runtime errors.Run the following script to check if
configFn
functions acceptformValues
as the second parameter:packages/effects/plugins/src/vxe-table/use-vxe-grid.vue (5)
29-29
: Import 'extendProxyOptions' added correctlyThe addition of
extendProxyOptions
is appropriate and necessary for extending proxy configurations later in the code.
42-42
: Introduction of 'FORM_SLOT_PREFIX' constant enhances maintainabilityDefining
FORM_SLOT_PREFIX = 'form-'
replaces hardcoded strings, improving code clarity and making future changes easier.
178-182
: Utilization of 'FORM_SLOT_PREFIX' in slot handlingReplacing hardcoded strings with
FORM_SLOT_PREFIX
indelegatedFormSlots
improves consistency and reduces the risk of typos.
197-197
: Enhance robustness by handling undefined form valuesUpdating
props.api.reload(formApi.form?.values ?? {});
ensures that an empty object is passed ifformApi.form.values
is undefined, preventing potential errors during reload.
208-209
: Extend proxy options to include form valuesThe call to
extendProxyOptions
effectively ensures that query-related events can access the form values, aligning with the updated form handling.
Description
Type of change
Please delete options that are not relevant.
pnpm-lock.yaml
unless you introduce a new test example.Checklist
pnpm run docs:dev
command.pnpm test
.feat:
,fix:
,perf:
,docs:
, orchore:
.Summary by CodeRabbit
New Features
pagerConfig
property to disable pagination in the basic grid example.releaseDate
field in the fixed grid example.Bug Fixes
Refactor