From 42aa2df62622ab380f97025819bd929fa0579e14 Mon Sep 17 00:00:00 2001 From: Luis Miguel Santos <127312735+luissantosHCIT@users.noreply.github.com> Date: Thu, 16 Oct 2025 21:55:31 -0400 Subject: [PATCH] fix 5323 unexpected series list filter change from all to recent (#5337) * fix to unexpected change from All to recent browser study lists because of the search order for the presence of the study in the tab groups and subsequent reset of the active tab state. Minor comment in the study browser header. Signed-off-by: Luis M. Santos * chore Added type annotations and cleaned up stylistically. Signed-off-by: Luis M. Santos * Tighten up a bit of the code to make it easier to follow * Fix warnings --------- Signed-off-by: Luis M. Santos Co-authored-by: Bill Wallace Confirm that Alireza's requested change was included. --- .../Panels/StudyBrowser/PanelStudyBrowser.tsx | 37 +++++++++---------- .../StudyBrowser/PanelStudyBrowserHeader.tsx | 1 + .../services/CustomizationService/types.ts | 3 +- .../core/src/utils/createStudyBrowserTabs.ts | 19 +++++++++- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/extensions/default/src/Panels/StudyBrowser/PanelStudyBrowser.tsx b/extensions/default/src/Panels/StudyBrowser/PanelStudyBrowser.tsx index 82aac7bd1..6d485dd79 100644 --- a/extensions/default/src/Panels/StudyBrowser/PanelStudyBrowser.tsx +++ b/extensions/default/src/Panels/StudyBrowser/PanelStudyBrowser.tsx @@ -7,6 +7,7 @@ import { PanelStudyBrowserHeader } from './PanelStudyBrowserHeader'; import { defaultActionIcons } from './constants'; import MoreDropdownMenu from '../../Components/MoreDropdownMenu'; import { CallbackCustomization } from 'platform/core/src/types'; +import { type TabsProps } from '@ohif/core/src/utils/createStudyBrowserTabs'; const { sortStudyInstances, formatDate, createStudyBrowserTabs } = utils; @@ -27,7 +28,7 @@ function PanelStudyBrowser({ const { servicesManager, commandsManager, extensionManager } = useSystem(); const { displaySetService, customizationService } = servicesManager.services; const navigate = useNavigate(); - const studyMode = customizationService.getCustomization('studyBrowser.studyMode') || 'all'; + const studyMode = (customizationService.getCustomization('studyBrowser.studyMode') as string) || 'all'; const internalImageViewer = useImageViewer(); const StudyInstanceUIDs = internalImageViewer.StudyInstanceUIDs; @@ -382,8 +383,8 @@ function PanelStudyBrowser({ } const displaySetInstanceUID = jumpToDisplaySet; - // Set the activeTabName and expand the study - const thumbnailLocation = _findTabAndStudyOfDisplaySet(displaySetInstanceUID, tabs); + // It is possible to navigate to a study not currently in view + const thumbnailLocation = _findTabAndStudyOfDisplaySet(displaySetInstanceUID, tabs, activeTabName); if (!thumbnailLocation) { return; } @@ -532,23 +533,21 @@ function getImageIdForThumbnail(displaySet, imageIds) { return imageId; } -function _findTabAndStudyOfDisplaySet(displaySetInstanceUID, tabs) { - for (let t = 0; t < tabs.length; t++) { - const { studies } = tabs[t]; +function _findTabAndStudyOfDisplaySet( + displaySetInstanceUID: string, + tabs: TabsProps, + currentTabName: string +) { + const current = tabs.find(tab => tab.name===currentTabName) || tabs[0]; + const biasedTabs = [current, ...tabs]; - for (let s = 0; s < studies.length; s++) { - const { displaySets } = studies[s]; - - for (let d = 0; d < displaySets.length; d++) { - const displaySet = displaySets[d]; - - if (displaySet.displaySetInstanceUID === displaySetInstanceUID) { - return { - tabName: tabs[t].name, - StudyInstanceUID: studies[s].studyInstanceUid, - }; - } - } + for (let t = 0; t < biasedTabs.length; t++) { + const study = biasedTabs[t].studies.find(study => study.displaySets.find(ds => ds.displaySetInstanceUID ===displaySetInstanceUID)); + if (study) { + return { + tabName: biasedTabs[t].name, + StudyInstanceUID: study.studyInstanceUid, + }; } } } diff --git a/extensions/default/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx b/extensions/default/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx index e5349b245..641daae5f 100644 --- a/extensions/default/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx +++ b/extensions/default/src/Panels/StudyBrowser/PanelStudyBrowserHeader.tsx @@ -14,6 +14,7 @@ function PanelStudyBrowserHeader({ actionIcons: actionIcon[]; updateActionIconValue: (actionIcon: actionIcon) => void; }) { + // Button order: Settings button then List view mode (thumbnails vs. list) return ( <>
diff --git a/platform/core/src/services/CustomizationService/types.ts b/platform/core/src/services/CustomizationService/types.ts index a0e0a7c44..71db214bd 100644 --- a/platform/core/src/services/CustomizationService/types.ts +++ b/platform/core/src/services/CustomizationService/types.ts @@ -45,7 +45,8 @@ export type Customization = | CommandCustomization | CodeCustomization | ComponentCustomization - | CallbackCustomization; + | CallbackCustomization + | string | number | boolean; export default Customization; diff --git a/platform/core/src/utils/createStudyBrowserTabs.ts b/platform/core/src/utils/createStudyBrowserTabs.ts index 09bdf5afa..7d2782ebf 100644 --- a/platform/core/src/utils/createStudyBrowserTabs.ts +++ b/platform/core/src/utils/createStudyBrowserTabs.ts @@ -1,5 +1,20 @@ import { useSystem } from '../contextProviders/SystemProvider'; +/** + * Tab properties that drive which tab group is used for thumbnail display. + */ +export type TabProp = { + name: string, + label: string, + studies: any[], +} + +/** + * Collection of tab properties with studies presorted depending on tab mod. + * This is used in deciding what thumbnails to show. + */ +export type TabsProps = TabProp[]; + /** * * @param {string[]} primaryStudyInstanceUIDs @@ -11,7 +26,7 @@ import { useSystem } from '../contextProviders/SystemProvider'; * @param {number} studyDisplayList.numInstances * @param {object[]} displaySets * @param {number} recentTimeframe - The number of milliseconds to consider a study recent - * @returns tabs - The prop object expected by the StudyBrowser component + * @returns {TabsProps} tabs - The prop object expected by the StudyBrowser component */ export function createStudyBrowserTabs( @@ -19,7 +34,7 @@ export function createStudyBrowserTabs( studyDisplayList, displaySets, recentTimeframeMS = 31536000000 -) { +): TabsProps { const { servicesManager } = useSystem(); const { displaySetService } = servicesManager.services;