* Fix export time picker on iOS

* Fix dialog on iPad
This commit is contained in:
Josh Hawkins 2024-09-27 07:52:31 -05:00 committed by GitHub
parent ddfdb71783
commit 1f328be1bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 8 deletions

View File

@ -22,7 +22,7 @@ import { FrigateConfig } from "@/types/frigateConfig";
import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover"; import { Popover, PopoverContent, PopoverTrigger } from "../ui/popover";
import { TimezoneAwareCalendar } from "./ReviewActivityCalendar"; import { TimezoneAwareCalendar } from "./ReviewActivityCalendar";
import { SelectSeparator } from "../ui/select"; import { SelectSeparator } from "../ui/select";
import { isDesktop } from "react-device-detect"; import { isDesktop, isIOS } from "react-device-detect";
import { Drawer, DrawerContent, DrawerTrigger } from "../ui/drawer"; import { Drawer, DrawerContent, DrawerTrigger } from "../ui/drawer";
import SaveExportOverlay from "./SaveExportOverlay"; import SaveExportOverlay from "./SaveExportOverlay";
import { getUTCOffset } from "@/utils/dateUtil"; import { getUTCOffset } from "@/utils/dateUtil";
@ -435,15 +435,18 @@ function CustomTimeSelector({
id="startTime" id="startTime"
type="time" type="time"
value={startClock} value={startClock}
step="1" step={isIOS ? "60" : "1"}
onChange={(e) => { onChange={(e) => {
const clock = e.target.value; const clock = e.target.value;
const [hour, minute, second] = clock.split(":"); const [hour, minute, second] = isIOS
? [...clock.split(":"), "00"]
: clock.split(":");
const start = new Date(startTime * 1000); const start = new Date(startTime * 1000);
start.setHours( start.setHours(
parseInt(hour), parseInt(hour),
parseInt(minute), parseInt(minute),
parseInt(second), parseInt(second ?? 0),
0, 0,
); );
setRange({ setRange({
@ -497,15 +500,18 @@ function CustomTimeSelector({
id="startTime" id="startTime"
type="time" type="time"
value={endClock} value={endClock}
step="1" step={isIOS ? "60" : "1"}
onChange={(e) => { onChange={(e) => {
const clock = e.target.value; const clock = e.target.value;
const [hour, minute, second] = clock.split(":"); const [hour, minute, second] = isIOS
const end = new Date(endTime * 1000); ? [...clock.split(":"), "00"]
: clock.split(":");
const end = new Date(startTime * 1000);
end.setHours( end.setHours(
parseInt(hour), parseInt(hour),
parseInt(minute), parseInt(minute),
parseInt(second), parseInt(second ?? 0),
0, 0,
); );
setRange({ setRange({

View File

@ -46,6 +46,7 @@ const DrawerContent = React.forwardRef<
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background", "fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
className, className,
isIOS && isPWA && "pb-5", isIOS && isPWA && "pb-5",
isIOS && !isPWA && "md:pb-5",
)} )}
{...props} {...props}
> >