Skip to content

Commit

Permalink
fix: user profile can not scroll by scrollbar
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Sep 6, 2024
1 parent 6873d21 commit eac1965
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/renderer/src/components/ui/markdown/components/Toc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { MarkdownRenderContainerRefContext } from "../context"
import type { TocItemProps } from "./TocItem"
import { TocItem } from "./TocItem"

type DebouncedFuncLeading<T extends (...args: any[]) => any> = T & {
type DebouncedFuncLeading<T extends (..._args: any[]) => any> = T & {
cancel: () => void
flush: () => void
}
Expand Down Expand Up @@ -218,7 +218,7 @@ export const Toc: Component = ({ className }) => {
{toc.map((heading, index) => (
<MemoedItem
heading={heading}
key={heading.title}
key={heading.anchorId}
rootDepth={rootDepth}
onClick={handleScrollTo}
isScrollOut={index < currentScrollRange[0]}
Expand Down Expand Up @@ -246,7 +246,7 @@ export const Toc: Component = ({ className }) => {
>
{toc.map((heading, index) => (
<li
key={heading.title}
key={heading.anchorId}
className="flex h-[24px] w-full items-center"
>
<button
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/components/ui/scroll-area/ScrollArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const Scrollbar = React.forwardRef<
<ScrollAreaBase.Scrollbar
{...rest}
ref={forwardedRef}
forceMount
className={cn(
"z-[99] flex w-2.5 touch-none select-none p-0.5",
orientation === "horizontal" ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ const EntryUser: Component<{
return (
<Tooltip>
<TooltipTrigger
className="relative"
className="no-drag-region relative cursor-pointer"
style={{
right: `${i * 8}px`,
zIndex: i,
}}
asChild
>
<m.button
layout="position"
layoutId={userId}
className="no-drag-region cursor-pointer"
type="button"
onClick={() => {
presentUserProfile(userId)
Expand Down
10 changes: 6 additions & 4 deletions src/renderer/src/modules/profile/user-profile-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ export const UserProfileModalContent: FC<{
if (!$ref) return

const initialHeaderHeight = 136
$ref.onscroll = throttle(() => {

const scrollHandler = throttle(() => {
const currentH = $ref.scrollTop

setHeaderSimple((current) => {
Expand All @@ -102,6 +103,7 @@ export const UserProfileModalContent: FC<{
return current
})
}, 16)
$ref.addEventListener("scroll", scrollHandler)

const currentVisible = new Set<string>()
const ob = new IntersectionObserver((en) => {
Expand All @@ -123,7 +125,7 @@ export const UserProfileModalContent: FC<{
ob.observe(el)
})
return () => {
$ref.onscroll = null
$ref.removeEventListener("scroll", scrollHandler)

ob.disconnect()
}
Expand Down Expand Up @@ -176,7 +178,7 @@ export const UserProfileModalContent: FC<{
>
<m.div
onPointerDown={stopPropagation}
onPointerDownCapture={stopPropagation}
// onPointerDownCapture={stopPropagation}
tabIndex={-1}
initial="initial"
animate={controller}
Expand Down Expand Up @@ -291,7 +293,7 @@ export const UserProfileModalContent: FC<{
</div>
<ScrollArea.ScrollArea
ref={setScrollerRef}
rootClassName="h-[400px] grow max-w-full px-5 w-full"
rootClassName="grow max-w-full px-5 w-full"
viewportClassName="[&>div]:space-y-4 pb-4"
>
{subscriptions.isLoading ? (
Expand Down

0 comments on commit eac1965

Please sign in to comment.