feat: Allow disabling auto-scroll using ui.disable-auto-scroll (#23462)
This commit is contained in:
1 parent
712467a7f4
commit
6b0726bcde
4 files changed
+14
-2
No files matched your search
@@ -8,6 +8,7 @@ import BookingPageTagManager from "@calcom/app-store/BookingPageTagManager";
|
||||
import { useIsPlatformBookerEmbed } from "@calcom/atoms/hooks/useIsPlatformBookerEmbed";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import PoweredBy from "@calcom/ee/components/PoweredBy";
|
||||
import { useEmbedUiConfig } from "@calcom/embed-core/embed-iframe";
|
||||
import { updateEmbedBookerState } from "@calcom/embed-core/src/embed-iframe";
|
||||
import TurnstileCaptcha from "@calcom/features/auth/Turnstile";
|
||||
import { useBookerStoreContext } from "@calcom/features/bookings/Booker/BookerStoreProvider";
|
||||
@@ -165,9 +166,14 @@ const BookerComponent = ({
|
||||
} = calendars;
|
||||
|
||||
const scrolledToTimeslotsOnce = useRef(false);
|
||||
|
||||
const embedUiConfig = useEmbedUiConfig();
|
||||
const scrollToTimeSlots = () => {
|
||||
if (isMobile && !scrolledToTimeslotsOnce.current && timeslotsRef.current) {
|
||||
if (
|
||||
isMobile &&
|
||||
!scrolledToTimeslotsOnce.current &&
|
||||
timeslotsRef.current &&
|
||||
!embedUiConfig.disableAutoScroll
|
||||
) {
|
||||
// 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
|
||||
scrollIntoViewSmooth(timeslotsRef.current, isEmbed);
|
||||
scrolledToTimeslotsOnce.current = true;
|
||||
|
||||
Reference in new issue
Block a user