-
Notifications
You must be signed in to change notification settings - Fork 516
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
Added scroll and responsiveness to the plots page #9815
Changes from 1 commit
1a6607d
623d7d1
24ce109
b6480b1
fbdad74
8eb6c3e
8b30429
4bf98ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,20 +43,22 @@ export const EncounterPlotsTab = (props: EncounterTabProps) => { | |
value={currentTabId} | ||
onValueChange={(value) => setQParams({ plot: value })} | ||
> | ||
<TabsList> | ||
{data.map((tab) => ( | ||
<TabsTrigger key={tab.id} value={tab.id}> | ||
{tab.name} | ||
</TabsTrigger> | ||
))} | ||
</TabsList> | ||
<div className="overflow-x-scroll w-full"> | ||
<TabsList> | ||
{data.map((tab) => ( | ||
<TabsTrigger key={tab.id} value={tab.id}> | ||
{tab.name} | ||
</TabsTrigger> | ||
))} | ||
</TabsList> | ||
</div> | ||
|
||
{data.map((tab) => ( | ||
<TabsContent key={tab.id} value={tab.id}> | ||
<ObservationVisualizer | ||
patientId={props.patient.id} | ||
codeGroups={tab.groups} | ||
gridCols={2} | ||
gridCols={window.innerWidth >= 768 ? 2 : 1} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix critical issues with window dimension handling The direct usage of
Consider using a proper window resize hook implementation: // hooks/useWindowSize.ts
import { useState, useEffect } from 'react';
import debounce from 'lodash/debounce';
export function useWindowSize() {
const [width, setWidth] = useState(0);
useEffect(() => {
// Initialize on client-side
setWidth(window.innerWidth);
const handleResize = debounce(() => {
setWidth(window.innerWidth);
}, 250);
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);
return width;
} Then update the component: + import { useWindowSize } from '@/hooks/useWindowSize';
export const EncounterPlotsTab = (props: EncounterTabProps) => {
+ const windowWidth = useWindowSize();
// ...
<ObservationVisualizer
patientId={props.patient.id}
codeGroups={tab.groups}
- gridCols={window.innerWidth >= 768 ? 2 : 1}
+ gridCols={windowWidth >= 768 ? 2 : 1}
/> Alternatively, consider using CSS Grid with media queries if the grid layout doesn't need to be controlled programmatically. |
||
/> | ||
</TabsContent> | ||
))} | ||
|
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.
instead of adding a div with className, we can simply add className to the parent Tabs component ryt?
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.
Yeah, I tried that but it gives scroll to the whole component including the plots idk if that behavior was wanted, looks weird to me...
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.
oh my bad. Tried on TabsList? lots of other usages seems to be working fine with TabsList
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.
Yeah, it gives a vertical scroll but not a horizontal scroll
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.
are you sure? it's working fine for me
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.
<TabsList className="overflow-x-scroll">
You're using this className?
<TabsList className="overflow-auto w-full">
using this it cuts out at left
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.
why does it cut out?
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.
like cuts out means it just overflows at left side
what classes are you using for it to work??