Skip to content

Fix: show descending sort arrow on Document Manager "Observed" column#159

Open
LiamStanziani wants to merge 1 commit into
MagentaHealth:release/2026-03-17from
openo-beta:bug/document-manager-datatables-default-order-arrow-missing-base-release
Open

Fix: show descending sort arrow on Document Manager "Observed" column#159
LiamStanziani wants to merge 1 commit into
MagentaHealth:release/2026-03-17from
openo-beta:bug/document-manager-datatables-default-order-arrow-missing-base-release

Conversation

@LiamStanziani

@LiamStanziani LiamStanziani commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

The Document Manager table (patient Document Manager and the provider eDoc tab) is configured to default-sort by the Observed (observation date) column, newest-first. The rows do render in the correct descending order, but the column header never shows the descending (down) arrow — it displays the neutral "unsorted" up/down glyph instead. This makes it look like the table isn't sorted by Observed date at all.

The cause is a one-character typo in the DataTables initialization: the sort direction was written as 'dsc' instead of 'desc'. This change corrects it.

Original PR: openo-beta#2486

As mentioned, this underlying issue was fixed, but this residual bug was found during the process of investigating this issue, so it was fixed.

Problem

src/main/webapp/documentManager/documentReport.jsp initializes the documents table with:

order: [[6, 'dsc']],   // column 6 = "Observed" (observation date)

'dsc' is not a valid DataTables direction (the valid values are 'asc' / 'desc'). Because of how DataTables 1.13.4 handles the value, the three pieces of "sorted" state diverge:

Aspect Result with 'dsc' Why
Row data order Descending (correct) The sort comparator only checks dir === 'asc'; anything else is treated as descending.
aria-sort attribute "descending" _fnSortAria uses dir == 'asc' ? 'ascending' : 'descending'.
Header arrow (CSS class) Neutral sorting (no arrow) The header renderer matches the direction exactly: dir == 'asc' ? sSortAsc : dir == 'desc' ? sSortDesc : <neutral>. 'dsc' matches neither branch, so the column falls back to the neutral glyph instead of sorting_desc.

So users see correctly-ordered rows but no visual indicator that the Observed column is the active (descending) sort.

The typo originates from commit d87797cb45 ("fix order grouping in document manager ordered by obs date desc"), which introduced the order option to fix an earlier "defaults to first column" bug. That commit fixed the data ordering but shipped the 'dsc' typo, leaving this residual cosmetic bug. It is present on both develop and release/2026-03-17, and affects both the patient Document Manager (function=demographic) and the provider eDoc tab (function=providers).

Solution

Change the DataTables sort direction from the invalid 'dsc' to the correct 'desc' in documentReport.jsp:

-                    order: [[6, 'desc']],
+                    order: [[6, 'desc']],

(Actual change: 'dsc''desc' on the order: line.)

This is a one-character, behavior-preserving fix: the data was already sorting descending, and now the header correctly renders the sorting_desc (down-arrow) class so the Observed column visibly shows it is the active descending sort.

UI Before:

image (3)

UI After:

image (4)

Verification

Verified live in the running app (logged in, demographic 1 + provider eDoc tab):

  • Before ('dsc'): Observed header class = sorting (neutral, no arrow); rows ordered descending.
  • After ('desc'): Observed header class = sorting sorting_desc (down arrow shown); rows ordered descending — identical data order, only the indicator changes.

Confirmed on both tables of the provider eDoc view (private tblDocs0 and published tblDocs1).

Summary by Sourcery

Bug Fixes:

  • Fix the DataTables configuration typo that prevented the Observed column header from displaying the descending sort arrow despite being sorted newest-first.

@LiamStanziani LiamStanziani self-assigned this Jun 25, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR fixes a typo in the DataTables configuration for the Document Manager / eDoc documents table so that the Observed column correctly displays the descending sort arrow while preserving the existing newest-first sort behavior.

Sequence diagram for DataTables initialization and Observed column sort arrow

sequenceDiagram
    participant Browser
    participant DocumentManager
    participant DataTables

    Browser->>DocumentManager: load documentReport.jsp
    DocumentManager->>DataTables: initialize DataTable(order [[6, desc]])
    DataTables->>DataTables: apply column 6 sort(desc)
    DataTables->>Browser: render rows(descending Observed)
    DataTables->>Browser: set header class(sorting_desc on Observed)
Loading

File-Level Changes

Change Details Files
Correct DataTables sort direction for the Observed column so the header shows the descending descending-arrow indicator while keeping the rows sorted newest-first.
  • Update the DataTables order configuration for the documents table to use the valid desc direction instead of the invalid dsc.
  • Ensure the Observed column remains the default sort key and that only the visual header state (sorting_desc class / arrow) changes, not the row order.
src/main/webapp/documentManager/documentReport.jsp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@LiamStanziani LiamStanziani marked this pull request as ready for review June 29, 2026 13:02

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@LiamStanziani LiamStanziani requested a review from lacarmen June 29, 2026 17:39
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.

1 participant