Skip to content

Commit

Permalink
3020: Fix unexpected scrolling behaviour in mobile desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
lunars97 committed Jan 26, 2025
1 parent 03f528f commit feb9bb7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ import { initSentry } from './utils/sentry'
const GlobalStyle = createGlobalStyle`
body {
/* Styling for react-tooltip: https://react-tooltip.com/docs/getting-started#styling */
position: relative;
--rt-color-dark: ${props => props.theme.colors.textSecondaryColor};
--rt-color-white: ${props => props.theme.colors.backgroundColor};
--rt-opacity: 1;
z-index:1;
}
`

Expand Down
13 changes: 10 additions & 3 deletions web/src/components/KebabMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement, ReactNode } from 'react'
import React, { ReactElement, ReactNode, useLayoutEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'

Expand Down Expand Up @@ -77,6 +77,13 @@ const StyledIcon = styled(Icon)`
const KebabMenu = ({ items, show, setShow, Footer }: KebabMenuProps): ReactElement | null => {
useLockedBody(show)
const { t } = useTranslation('layout')
const [scrollY, setScrollY] = useState<number>(0)

useLayoutEffect(() => {
if (show) {
setScrollY(window.scrollY)
}
}, [show])

const onClick = () => {
setShow(!show)
Expand All @@ -95,8 +102,8 @@ const KebabMenu = ({ items, show, setShow, Footer }: KebabMenuProps): ReactEleme
className='kebab-menu'
show={show}
style={{
visibility: show ? 'visible' : 'hidden',
top: window.scrollY > 0 ? `${window.scrollY}px` : undefined,
display: show ? 'block' : 'none',
top: scrollY > 0 ? `${scrollY}px` : undefined,
}}>
{/* disabled because this is an overlay for backdrop close */}
{/* eslint-disable-next-line styled-components-a11y/no-static-element-interactions,styled-components-a11y/click-events-have-key-events */}
Expand Down
1 change: 1 addition & 0 deletions web/src/styles/KebabMenu.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
width: 100%;
height: 100%;
overflow: hidden;
z-index: 10;
}

0 comments on commit feb9bb7

Please sign in to comment.