Skip to content

Commit

Permalink
remove workaround to make popovers follow their target on scroll, it …
Browse files Browse the repository at this point in the history
…causes lagging issues and was fixed in mantinedev/mantine#3351 (#1087)
  • Loading branch information
Athou committed Jun 20, 2023
1 parent 4f699d9 commit 4f644ba
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions commafeed-client/src/components/content/FeedEntryFooter.tsx
Expand Up @@ -7,17 +7,14 @@ import { useAppDispatch, useAppSelector } from "app/store"
import { Entry } from "app/types"
import { ActionButton } from "components/ActionButtton"
import { ButtonToolbar } from "components/ButtonToolbar"
import { useEffect, useState } from "react"
import { TbArrowBarToDown, TbExternalLink, TbEyeCheck, TbEyeOff, TbShare, TbStar, TbStarOff, TbTag } from "react-icons/tb"
import { throttle } from "throttle-debounce"
import { ShareButtons } from "./ShareButtons"

interface FeedEntryFooterProps {
entry: Entry
}

export function FeedEntryFooter(props: FeedEntryFooterProps) {
const [scrollPosition, setScrollPosition] = useState(0)
const sharingSettings = useAppSelector(state => state.user.settings?.sharingSettings)
const tags = useAppSelector(state => state.user.tags)
const mobile = !useMediaQuery(`(min-width: ${Constants.layout.mobileBreakpoint})`)
Expand All @@ -34,16 +31,6 @@ export function FeedEntryFooter(props: FeedEntryFooterProps) {
})
)

useEffect(() => {
const scrollArea = document.getElementById(Constants.dom.mainScrollAreaId)

const listener = () => setScrollPosition(scrollArea ? scrollArea.scrollTop : 0)
const throttledListener = throttle(100, listener)

scrollArea?.addEventListener("scroll", throttledListener)
return () => scrollArea?.removeEventListener("scroll", throttledListener)
}, [])

return (
<Group position="apart">
<ButtonToolbar>
Expand All @@ -61,7 +48,7 @@ export function FeedEntryFooter(props: FeedEntryFooterProps) {
/>

{showSharingButtons && (
<Popover withArrow withinPortal shadow="md" positionDependencies={[scrollPosition]} closeOnClickOutside={!mobile}>
<Popover withArrow withinPortal shadow="md" closeOnClickOutside={!mobile}>
<Popover.Target>
<ActionButton icon={<TbShare size={18} />} label={<Trans>Share</Trans>} />
</Popover.Target>
Expand All @@ -72,7 +59,7 @@ export function FeedEntryFooter(props: FeedEntryFooterProps) {
)}

{tags && (
<Popover withArrow withinPortal shadow="md" positionDependencies={[scrollPosition]} closeOnClickOutside={!mobile}>
<Popover withArrow withinPortal shadow="md" closeOnClickOutside={!mobile}>
<Popover.Target>
<Indicator label={props.entry.tags.length} disabled={props.entry.tags.length === 0} inline size={16}>
<ActionButton icon={<TbTag size={18} />} label={<Trans>Tags</Trans>} />
Expand Down

0 comments on commit 4f644ba

Please sign in to comment.