Skip to content

Set default enableSorting and enableHiding to false#3070

Merged
MdAsifHossainNadim merged 5 commits intodevelopfrom
set-enableSorting-and-enableHiding-fields-default-value-false
Jan 27, 2026
Merged

Set default enableSorting and enableHiding to false#3070
MdAsifHossainNadim merged 5 commits intodevelopfrom
set-enableSorting-and-enableHiding-fields-default-value-false

Conversation

@akzmoudud
Copy link
Contributor

@akzmoudud akzmoudud commented Jan 13, 2026

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

Related Pull Request(s)

Closes

How to test the changes in this Pull Request:

  • Steps or issue link

Changelog entry

Title
Default table interactions have been refined

Before Changes

Describe the issue before changes with screenshots(s).

After Changes

Describe the issue after changes with screenshot(s).

Feature Video (optional)

Link of detailed video if this PR is for a feature.

PR Self Review Checklist:

  • Code is not following code style guidelines
  • Bad naming: make sure you would understand your code if you read it a few months from now.
  • KISS: Keep it simple, Sweetie (not stupid!).
  • DRY: Don't Repeat Yourself.
  • Code that is not readable: too many nested 'if's are a bad sign.
  • Performance issues
  • Complicated constructions that need refactoring or comments: code should almost always be self-explanatory.
  • Grammar errors.

FOR PR REVIEWER ONLY:

As a reviewer, your feedback should be focused on the idea, not the person. Seek to understand, be respectful, and focus on constructive dialog.

As a contributor, your responsibility is to learn from suggestions and iterate your pull request should it be needed based on feedback. Seek to collaborate and produce the best possible contribution to the greater whole.

  • Correct — Does the change do what it’s supposed to? ie: code 100% fulfilling the requirements?
  • Secure — Would a nefarious party find some way to exploit this change? ie: everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities?
  • Readable — Will your future self be able to understand this change months down the road?
  • Elegant — Does the change fit aesthetically within the overall style and architecture?

Summary by CodeRabbit

  • Updates
    • Disabled sorting for multiple columns (Date, Amount, Vendor, Charge, Payable, Registered) across admin transaction and vendor tables.
    • Disabled column hiding for admin data tables, making column visibility fixed in admin views.

✏️ Tip: You can customize this high-level summary in your review settings.

@akzmoudud akzmoudud self-assigned this Jan 13, 2026
@akzmoudud akzmoudud requested a review from mrabbani January 13, 2026 05:21
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

Multiple admin table pages had sorting disabled on several columns; core DataView components now normalize fields to set enableSorting: false and enableHiding: false by default.

Changes

Cohort / File(s) Summary
Reverse Withdrawal Pages
src/admin/dashboard/pages/reverse-withdrawal/ReverseWithdrawalTransaction.tsx, src/admin/dashboard/pages/reverse-withdrawal/index.tsx
Disabled sorting for Date and Amount (enableSorting: false) in reverse-withdrawal table field configs.
Withdraw & Vendors Pages
src/admin/dashboard/pages/withdraw/index.tsx, src/admin/dashboard/pages/vendors.tsx
Disabled sorting for multiple columns (Vendor, Amount, Charge, Payable, Date, Registered) and made Withdraw page fields explicit (changed visible column order).
Core DataView Components
src/components/dataviews/AdminDataViewTable.tsx, src/components/dataviews/DataViewTable.tsx
Added normalization that maps each field to enableSorting: false and enableHiding: false, and uses these normalized fields when applying filters to table elements.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Upcoming Release

Suggested reviewers

  • mrabbani

Poem

🐰 I hopped through columns, one by one,
Turned off the sorts till the day was done.
No more tumbling headers or frantic chase,
Just tidy rows in a peaceful space.
🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description lacks critical information required by the template, including detailed explanation of changes, testing steps, and before/after documentation. Add comprehensive details: explain why sorting/hiding defaults changed, provide testing steps, include before/after screenshots, and fill in the 'Changes proposed' section with technical specifics.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: disabling sorting and column hiding by default across the codebase.
Linked Issues check ✅ Passed The PR addresses the linked issues by disabling sorting and hiding by default in DataViewTable components and specific admin pages, which directly resolves reported sorting/visibility inconsistencies [#5321].
Out of Scope Changes check ✅ Passed All changes are focused on disabling enableSorting and enableHiding fields; no unrelated modifications detected outside the stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🤖 Fix all issues with AI agents
In @src/components/dataviews/DataViewTable.tsx:
- Around line 74-81: The code sets column defaults after spreading each field so
per-field settings get overwritten; update the normalizedFields mapping to apply
defaults first and then spread field properties (i.e., { enableSorting: false,
enableHiding: false, ...field }) so any explicit field.enableSorting or
field.enableHiding values take precedence (refer to the normalizedFields mapping
where fields.map is used).
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e2b84c and 01b0290.

📒 Files selected for processing (6)
  • src/admin/dashboard/pages/reverse-withdrawal/ReverseWithdrawalTransaction.tsx
  • src/admin/dashboard/pages/reverse-withdrawal/index.tsx
  • src/admin/dashboard/pages/vendors.tsx
  • src/admin/dashboard/pages/withdraw/index.tsx
  • src/components/dataviews/AdminDataViewTable.tsx
  • src/components/dataviews/DataViewTable.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
src/components/dataviews/DataViewTable.tsx (1)
src/vendor-dashboard/reports/analytics/components/report-chart/index.js (1)
  • fields (351-351)
⏰ 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). (4)
  • GitHub Check: api tests (1, 1)
  • GitHub Check: e2e tests (1, 3)
  • GitHub Check: e2e tests (2, 3)
  • GitHub Check: e2e tests (3, 3)
🔇 Additional comments (7)
src/admin/dashboard/pages/withdraw/index.tsx (1)

108-218: LGTM! Explicit sorting disable aligns with PR objectives.

The explicit enableSorting: false on Vendor, Amount, Charge, Payable, and Date fields correctly addresses the UI issues. While AdminDataViewTable now applies global normalization with enableSorting: false by default, these explicit declarations serve as clear documentation of intent and provide safety if the global behavior changes in the future.

src/admin/dashboard/pages/reverse-withdrawal/ReverseWithdrawalTransaction.tsx (1)

65-76: LGTM!

Disabling sorting on the Date field addresses the reported UI issue where sorting controls were present but non-functional.

src/components/dataviews/AdminDataViewTable.tsx (2)

95-102: LGTM! Correct spread order for default normalization.

The normalization correctly places defaults before the field spread, allowing individual fields to override these defaults if needed in the future. This is the right pattern for maintainability and extensibility.


114-119: Correctly applies normalized fields to the filter pipeline.

src/admin/dashboard/pages/reverse-withdrawal/index.tsx (1)

67-88: LGTM!

Sorting disabled on Amount and Date fields, consistent with the broader PR objective to disable non-functional sorting controls.

src/components/dataviews/DataViewTable.tsx (1)

113-118: Correctly applies normalized fields to the filter pipeline.

src/admin/dashboard/pages/vendors.tsx (1)

326-326: Change aligns with PR objectives.

Disabling sorting for the 'registered' column is consistent with the fix for broken sorting UI. However, note that:

  1. The initial view state (line 35) still sets sort: { field: 'registered', direction: 'desc' }
  2. Lines 159-166 contain sorting logic specifically handling the 'registered' field

This means data will load pre-sorted by registration date, but users cannot change it via UI—which may be intentional. If the goal is to restore sorting functionality later, the backend logic is preserved. Otherwise, consider adding a comment clarifying that the default sort order is intentional while user-controlled sorting is disabled.

@mrabbani mrabbani added Dev Review Done Needs: Testing This requires further testing labels Jan 13, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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)
src/admin/dashboard/pages/withdraw/index.tsx (1)

694-749: Pre-existing: Polling logic has a minor issue with the initial call.

This is pre-existing code, but worth noting: on line 748, checkStatus() is called without the resolve parameter. Inside checkStatus, when resolve is undefined, the function still completes but the outer await may not behave as expected during the recursive polling. The current implementation works because resolve?.() is safely guarded, but this pattern could be simplified.

♻️ Consider a cleaner polling approach
-    const pollExportStatus = async ( exportId ) => {
-        const maxAttempts = 60; // Maximum 5 minutes (60 * 5 seconds)
-        let attempts = 0;
-
-        const checkStatus = async ( resolve ) => {
-            try {
-                const statusResponse = await apiFetch( {
-                    path: `/dokan/v1/reports/withdraws/export/${ exportId }/status`,
-                    method: 'GET',
-                } );
-
-                console.log( 'Export status:', statusResponse );
-
-                if ( statusResponse.percent_complete === 100 ) {
-                    // Export is complete, download the file
-                    if ( statusResponse.download_url ) {
-                        // Create a temporary link to download the file
-                        const link = document.createElement( 'a' );
-                        link.href = statusResponse.download_url;
-                        link.download = ''; // Let the browser determine the filename
-                        document.body.appendChild( link );
-                        link.click();
-                        document.body.removeChild( link );
-
-                        console.log( 'Export completed and downloaded' );
-                    } else {
-                        throw new Error( 'Download URL not available' );
-                    }
-                } else {
-                    // Still processing, check again
-                    attempts++;
-                    if ( attempts < maxAttempts ) {
-                        await new Promise(
-                            ( res ) =>
-                                setTimeout(
-                                    async () => await checkStatus( res ),
-                                    5000
-                                ) // Check again in 5 seconds
-                        );
-                    } else {
-                        throw new Error( 'Export timeout - please try again' );
-                    }
-                }
-            } catch ( error ) {
-                console.error( 'Error checking export status:', error );
-                alert( __( 'Export failed. Please try again.', 'dokan-lite' ) );
-            }
-
-            if ( resolve ) {
-                resolve();
-            }
-        };
-
-        // Start status checking
-        await checkStatus();
-    };
+    const pollExportStatus = async ( exportId ) => {
+        const maxAttempts = 60;
+        const delayMs = 5000;
+
+        for ( let attempt = 0; attempt < maxAttempts; attempt++ ) {
+            try {
+                const statusResponse = await apiFetch( {
+                    path: `/dokan/v1/reports/withdraws/export/${ exportId }/status`,
+                    method: 'GET',
+                } );
+
+                if ( statusResponse.percent_complete === 100 ) {
+                    if ( ! statusResponse.download_url ) {
+                        throw new Error( 'Download URL not available' );
+                    }
+                    const link = document.createElement( 'a' );
+                    link.href = statusResponse.download_url;
+                    link.download = '';
+                    document.body.appendChild( link );
+                    link.click();
+                    document.body.removeChild( link );
+                    return;
+                }
+
+                await new Promise( ( r ) => setTimeout( r, delayMs ) );
+            } catch ( error ) {
+                console.error( 'Error checking export status:', error );
+                alert( __( 'Export failed. Please try again.', 'dokan-lite' ) );
+                return;
+            }
+        }
+
+        alert( __( 'Export timeout - please try again.', 'dokan-lite' ) );
+    };
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ccccd3 and 894af59.

📒 Files selected for processing (1)
  • src/admin/dashboard/pages/withdraw/index.tsx
⏰ 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). (4)
  • GitHub Check: e2e tests (2, 3)
  • GitHub Check: e2e tests (3, 3)
  • GitHub Check: e2e tests (1, 3)
  • GitHub Check: api tests (1, 1)
🔇 Additional comments (2)
src/admin/dashboard/pages/withdraw/index.tsx (2)

108-218: Sorting disabled on selected columns aligns with PR objective.

The enableSorting: false additions to vendor, amount, charge, payable, and date fields address the reported UI issues where sorting controls weren't functioning.

Note that status, method, details, and note fields don't explicitly set enableSorting. Per the PR title, if the default is now false at the DataView component level, this is consistent. However, if any of these fields should remain sortable (e.g., status or date), verify that the backend API actually supports sorting on those fields before re-enabling.


515-524: Explicit fields array correctly excludes vendor since it's used as titleField.

The hardcoded fields list intentionally omits vendor because it's specified as titleField on line 512, meaning it's rendered as the primary row identifier rather than a regular column. This is consistent with DataView patterns where the title field receives special treatment.

@dev-shahed dev-shahed added 🎉 QA Approved This PR is approved by the QA team and removed Needs: Testing This requires further testing QA In Progress labels Jan 26, 2026
@dev-shahed
Copy link
Member

Note: this PR partially solve the issue, not close the issue

@MdAsifHossainNadim MdAsifHossainNadim merged commit 1d918f7 into develop Jan 27, 2026
1 of 6 checks passed
@MdAsifHossainNadim MdAsifHossainNadim deleted the set-enableSorting-and-enableHiding-fields-default-value-false branch January 27, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dev Review Done 🎉 QA Approved This PR is approved by the QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants