Merged in feature/SW-2320-languagebased-hide-for-next-release (pull request #1937)

Language based alternative to HIDE_FOR_NEXT_RELEASE

Approved-by: Anton Gunnarsson
This commit is contained in:
Joakim Jäderberg
2025-05-05 10:53:28 +00:00
parent 3bcf6cff4a
commit 5784822a1e
41 changed files with 232 additions and 133 deletions

View File

@@ -2,7 +2,6 @@
import { useCallback, useEffect, useState } from "react"
import { env } from "@/env/client"
import useStickyPositionStore, {
type StickyElement,
type StickyElementNameEnum,
@@ -10,6 +9,8 @@ import useStickyPositionStore, {
import { debounce } from "@/utils/debounce"
import { useIsLangLive } from "./useIsLangLive"
interface UseStickyPositionProps {
ref?: React.RefObject<HTMLElement>
name?: StickyElementNameEnum
@@ -46,6 +47,7 @@ export default function useStickyPosition({
getAllElements,
} = useStickyPositionStore()
const isLangLive = useIsLangLive()
/* Used for Current mobile header since that doesn't use this hook.
*
* Instead, calculate if the mobile header is shown and add the height of
@@ -123,7 +125,7 @@ export default function useStickyPosition({
updateHeights()
// Only do this special handling if we have the current header
if (env.NEXT_PUBLIC_HIDE_FOR_NEXT_RELEASE) {
if (!isLangLive) {
if (document.body.clientWidth > 950) {
setBaseTopOffset(0)
} else {
@@ -142,7 +144,7 @@ export default function useStickyPosition({
resizeObserver.unobserve(document.body)
}
}
}, [updateHeights])
}, [updateHeights, isLangLive])
return {
currentHeight: ref?.current?.offsetHeight || null,