fix: Scrolling to timeslot issue on Safari with inline-embeds (#22547)
* Add playground * Fix scroll issue on safari
This commit is contained in:
1 parent
fa47456d5f
commit
7813d3739f
15 files changed
+657
-19
No files matched your search
@@ -13,6 +13,7 @@ import TurnstileCaptcha from "@calcom/features/auth/Turnstile";
|
||||
import useSkipConfirmStep from "@calcom/features/bookings/Booker/components/hooks/useSkipConfirmStep";
|
||||
import { getQueryParam } from "@calcom/features/bookings/Booker/utils/query-param";
|
||||
import { useNonEmptyScheduleDays } from "@calcom/features/schedules/lib/use-schedule/useNonEmptyScheduleDays";
|
||||
import { scrollIntoViewSmooth } from "@calcom/lib/browser/browser.utils";
|
||||
import { PUBLIC_INVALIDATE_AVAILABLE_SLOTS_ON_BOOKING_FORM } from "@calcom/lib/constants";
|
||||
import { CLOUDFLARE_SITE_ID, CLOUDFLARE_USE_TURNSTILE_IN_BOOKER } from "@calcom/lib/constants";
|
||||
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
||||
@@ -154,10 +155,11 @@ const BookerComponent = ({
|
||||
} = calendars;
|
||||
|
||||
const scrolledToTimeslotsOnce = useRef(false);
|
||||
|
||||
const scrollToTimeSlots = () => {
|
||||
if (isMobile && !scrolledToTimeslotsOnce.current) {
|
||||
if (isMobile && !scrolledToTimeslotsOnce.current && timeslotsRef.current) {
|
||||
// eslint-disable-next-line @calcom/eslint/no-scroll-into-view-embed -- We are allowing it here because scrollToTimeSlots is called on explicit user action where it makes sense to scroll, remember that the goal is to not do auto-scroll on embed load because that ends up scrolling the embedding webpage too
|
||||
timeslotsRef.current?.scrollIntoView({ behavior: "smooth" });
|
||||
scrollIntoViewSmooth(timeslotsRef.current, isEmbed);
|
||||
scrolledToTimeslotsOnce.current = true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user