You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This adds react-use-measure to adjust the top of the picker if it flows over the top of the page. It might also need to adjust the bottom, but I haven't run into this issue yet. Check the changes in PopoverContent
Lastly, for completeness, here's my implementation of hooks/use-breakpoint.ts
hooks/use-breakpoint.tsx
'use client';import{useEffect,useState}from'react';// Breakpoints from tailwind: https://tailwindcss.com/docs/responsive-designexportenumBreakpoint{SM='640',MD='768',LG='1024',XL='1280','2XL'='1536',}// Global subscription manager for resize eventsconstsubscribers=newSet<(width: number)=>void>();letglobalResizeObserver: ResizeObserver|null=null;functioninitGlobalResizeObserver(){// Ensure that only one global observer is createdif(globalResizeObserver===null&&typeofdocument!=='undefined'){globalResizeObserver=newResizeObserver((entries)=>{constwidth=entries[0].contentRect.width;subscribers.forEach((callback)=>callback(width));});globalResizeObserver.observe(document.body);}}/** * Hook to check if the current viewport is below a given breakpoint using a global ResizeObserver * @param breakpoint The breakpoint to check against (in pixels) * @returns boolean indicating if the viewport is below the breakpoint */exportconstuseBreakpoint=(breakpoint: keyoftypeofBreakpoint)=>{const[isBelow,setIsBelow]=useState(false);useEffect(()=>{constcheckBreakpoint=(width: number)=>{setIsBelow(width<Number(Breakpoint[breakpoint]));};// Initialize the global resize observer if it hasn't been alreadyinitGlobalResizeObserver();// Add this instance's callback to the subscriberssubscribers.add(checkBreakpoint);// Ensure the current width is applied immediatelycheckBreakpoint(window.innerWidth);return()=>{// Clean up by removing this callback from subscribers on unmountsubscribers.delete(checkBreakpoint);};},[breakpoint]);returnisBelow;};
The text was updated successfully, but these errors were encountered:
The DateRange picker overflows on mobile, it should break into flex-col when small. I fixed this on my own app, thought I'd share:
I'll abbreviate the code to highlight the changes
Calendar.tsx
date-range-picker.tsx
This adds
react-use-measure
to adjust the top of the picker if it flows over the top of the page. It might also need to adjust the bottom, but I haven't run into this issue yet. Check the changes inPopoverContent
Lastly, for completeness, here's my implementation of
hooks/use-breakpoint.ts
hooks/use-breakpoint.tsx
The text was updated successfully, but these errors were encountered: