Skip to content

Dashboard: Fix domain expiry sort crash when expiry is undefined#108645

Merged
fushar merged 6 commits intotrunkfrom
StevenDufresne/fix-domain-expiry-sort
Feb 13, 2026
Merged

Dashboard: Fix domain expiry sort crash when expiry is undefined#108645
fushar merged 6 commits intotrunkfrom
StevenDufresne/fix-domain-expiry-sort

Conversation

@StevenDufresne
Copy link
Copy Markdown
Contributor

@StevenDufresne StevenDufresne commented Feb 11, 2026

Fixes CALYPSO-2HDV
Fixes DOTMSD-1092

Proposed Changes

  • Extract a generic sortNullableStrings comparator into its own module for reuse and testability.
  • Fix the sort function to compare getValue results directly instead of accessing .expiry on them. The @wordpress/dataviews library calls getValue on each item first, then passes those results to field.sort — the original code incorrectly treated the sort arguments as full DomainSummary objects.
  • Add unit tests covering null, undefined, ascending, descending, and equal value cases.

Why are these changes being made?

The domain expiry sort in the Dashboard domains DataView was broken in two ways:

  1. It only guarded against null expiry values, but some domains have undefined expiry at runtime, causing a TypeError crash (CALYPSO-2HDV — 4 occurrences, 3 users impacted).
  2. Even without the crash, the sort never worked correctly because the @wordpress/dataviews library wraps field.sort — it calls getValue first and passes the category strings ('1-expired', '2-next-90-days', '3-more-than-90-days') to sort, not full DomainSummary objects. The old code did a.expiry.localeCompare(b.expiry) on these strings, which silently failed.

Testing Instructions

  • Navigate to the Domains page in the Dashboard (/domains)
  • Sort domains by the "Paid until" column (click the column header)
  • Verify expired domains sort before expiring-soon domains, which sort before others
  • Verify toggling the sort direction reverses the order
  • Verify domains with no expiry date sort to the end

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you tested accessibility for your changes? Ensure the feature remains usable with various user agents (e.g., browsers), interfaces (e.g., keyboard navigation), and assistive technologies (e.g., screen readers) (PCYsg-S3g-p2).
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

Fixes CALYPSO-2HDV

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@matticbot
Copy link
Copy Markdown
Contributor

matticbot commented Feb 11, 2026

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • help-center
  • notifications

To test WordPress.com changes, run install-plugin.sh $pluginSlug StevenDufresne/fix-domain-expiry-sort on your sandbox.

StevenDufresne and others added 2 commits February 12, 2026 11:35
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The dataviews library passes getValue results to field.sort, not
full items. The sort function was accessing .expiry on category
strings, which silently returned undefined.

Fixes CALYPSO-2HDV

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@StevenDufresne StevenDufresne marked this pull request as ready for review February 12, 2026 05:43
@StevenDufresne StevenDufresne requested a review from a team as a code owner February 12, 2026 05:43
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 12, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@fushar fushar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, works.

Comment thread client/dashboard/domains/dataviews/sort-by-expiry.ts Outdated
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@StevenDufresne StevenDufresne force-pushed the StevenDufresne/fix-domain-expiry-sort branch from 6e62e76 to a22ab2f Compare February 13, 2026 03:04
* Sort comparator for nullable string field values. Null/undefined values sort
* to the end regardless of direction.
*
* Note: Despite the Field<Item> type declaring sort as (a: Item, b: Item, ...),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is now not necessary :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐒 🙈

@fushar
Copy link
Copy Markdown
Contributor

fushar commented Feb 13, 2026

I'll commandeer this. It seems to have broken production in my case 😬

Comment thread client/dashboard/domains/dataviews/sort-nullable-strings.ts Outdated
@fushar fushar merged commit 9175743 into trunk Feb 13, 2026
13 of 14 checks passed
@fushar fushar deleted the StevenDufresne/fix-domain-expiry-sort branch February 13, 2026 13:09
@github-actions github-actions Bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 13, 2026
@StevenDufresne
Copy link
Copy Markdown
Contributor Author

Thanks. I was coming online to do so today :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants