fix(BOOK-152): Removed old header references inside useStickyPosition hook to fix offset issue for the sitewide alert
Approved-by: Matilda Landström
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
import { useCallback, useEffect } from "react"
|
||||
|
||||
import useStickyPositionStore, {
|
||||
type StickyElement,
|
||||
@@ -43,15 +43,7 @@ export default function useStickyPosition({
|
||||
updateHeights,
|
||||
getAllElements,
|
||||
} = useStickyPositionStore()
|
||||
|
||||
/* 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
|
||||
* that "manually" to all offsets using this hook.
|
||||
*
|
||||
* TODO: Remove this and just use 0 when the current header has been removed.
|
||||
*/
|
||||
const [baseTopOffset, setBaseTopOffset] = useState(0)
|
||||
const baseTopOffset = 0
|
||||
|
||||
useEffect(() => {
|
||||
if (ref && name) {
|
||||
@@ -119,13 +111,6 @@ export default function useStickyPosition({
|
||||
if (!resizeObserver) {
|
||||
const debouncedResizeHandler = debounce(() => {
|
||||
updateHeights()
|
||||
|
||||
// Only do this special handling if we have the current header
|
||||
if (document.body.clientWidth > 950) {
|
||||
setBaseTopOffset(0)
|
||||
} else {
|
||||
setBaseTopOffset(52.41) // The height of current mobile header
|
||||
}
|
||||
}, 100)
|
||||
|
||||
resizeObserver = new ResizeObserver(debouncedResizeHandler)
|
||||
|
||||
Reference in New Issue
Block a user