File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {itemActiveDescendantClass} from '../ActionList/Item'
1111import { useProvidedStateOrCreate } from '../hooks/useProvidedStateOrCreate'
1212import styled from 'styled-components'
1313import { get } from '../constants'
14+ import useScrollFlash from '../hooks/useScrollFlash'
1415
1516export interface FilteredActionListProps extends Partial < Omit < GroupedListProps , keyof ListPropsBase > > , ListPropsBase {
1617 loading ?: boolean
@@ -121,6 +122,8 @@ export function FilteredActionList({
121122 }
122123 } , [ items ] )
123124
125+ useScrollFlash ( scrollContainerRef )
126+
124127 return (
125128 < Flex ref = { containerRef } flexDirection = "column" overflow = "hidden" >
126129 < StyledHeader >
Original file line number Diff line number Diff line change 1+ import React , { useEffect } from 'react'
2+ /**
3+ * This hook will flash the scrollbars for a ref of a container that has scrollable overflow
4+ * @param scrollContainerRef The ref of the scrollable content
5+ */
6+ export default function useScrollFlash ( scrollContainerRef : React . RefObject < HTMLElement > ) {
7+ // https://adxlv.computer/projects/flash-scrollers/
8+ useEffect ( ( ) => {
9+ const scrollContainer = scrollContainerRef . current
10+ if ( ! scrollContainer ) {
11+ return
12+ }
13+ const currentScroll = scrollContainer . scrollTop
14+ const maxScroll = scrollContainer . scrollHeight
15+
16+ const altScroll = currentScroll < Math . min ( 1 , maxScroll ) ? currentScroll + 1 : currentScroll - 1
17+
18+ scrollContainer . scrollTop = altScroll
19+ scrollContainer . scrollTop = currentScroll
20+ } , [ scrollContainerRef ] )
21+ }
You can’t perform that action at this time.
0 commit comments