@@ -9,6 +9,7 @@ import { IconTrashXFilled } from '@tabler/icons-react';
9
9
import useOnClickOutside from '../hooks/useHooks/useOnClickOutside' ;
10
10
import { useDefaults } from '../hooks/useDefaults' ;
11
11
import SVGIcon from './SVGIcon' ;
12
+ import { CSSProperties } from 'react' ;
12
13
13
14
const DEFAULTS = { fontSizeClass : 'text-xs' } ;
14
15
@@ -77,6 +78,12 @@ export default function KernDropdown(props: KernDropdownProps) {
77
78
}
78
79
} , [ props . positionDropdown ] ) ;
79
80
81
+ const scrollMaxStyles = useMemo ( ( ) : CSSProperties => {
82
+ if ( ! props . scrollAfterNOptions ) return { } ;
83
+ const maxHeight = 2 * props . scrollAfterNOptions + 0.5 ;
84
+ return { "maxHeight" : `${ maxHeight } rem` , "overflowY" : "auto" } ;
85
+ } , [ props . scrollAfterNOptions ] ) ;
86
+
80
87
function setOptionsWithCheckboxes ( options : any [ ] ) {
81
88
if ( selectedCheckboxes . length > 0 ) return ;
82
89
const newSelectedCheckboxes = options . map ( ( option : any , index : number ) => {
@@ -218,7 +225,7 @@ export default function KernDropdown(props: KernDropdownProps) {
218
225
show = { isOpen }
219
226
>
220
227
< Menu . Items className = { `absolute z-10 mt-2 origin-top-right rounded-md bg-white shadow-sm ring-1 ring-black ring-opacity-5 focus:outline-none ${ props . dropdownItemsWidth ?? 'w-full' } ${ props . dropdownItemsClasses ?? '' } ${ positionDropdown } ` } >
221
- < div className = " py-1" >
228
+ < div style = { scrollMaxStyles } className = ' py-1' >
222
229
{ dropdownCaptions . map ( ( option : any , index : number ) => (
223
230
< div key = { option + "-" + index } className = 'relative' >
224
231
< Menu . Item disabled = { disabledOptions [ index ] } >
0 commit comments