@@ -55,46 +55,57 @@ const AttributeButtonPopover = <T extends ReactText>({
5555 filterable = false ,
5656 isOpen,
5757} : AttributeButtonPopoverProps < T > ) => {
58- const AttributeSelect = Select . ofType < T > ( ) ;
5958 const itemPredicate = ( query : string , item : T ) => {
6059 return String ( item ) . toLowerCase ( ) . includes ( query . toLowerCase ( ) ) ;
6160 } ;
6261 const [ sliderValue , setSliderValue ] = useState ( 0 ) ;
6362 useEffect ( ( ) => {
6463 setSliderValue ( Number ( currentValue ) ) ;
6564 } , [ isOpen , currentValue ] ) ;
65+
66+ const formatDisplayText = ( text : string ) : string => {
67+ // TODO: for doantrang982/eng-77-decouple-display-from-output: Create formatDisplayText from configPage
68+ // const match = text.match(/\[\[(.*?)\]\]/);
69+ // if (match && match[1]) {
70+ // return match[1];
71+ // }
72+ return text ;
73+ } ;
74+
75+ // Only show filter if we have more than 10 items
76+ const shouldFilter = filterable && items . length > 10 ;
77+
6678 return (
67- < AttributeSelect
79+ < MenuItemSelect
6880 className = "inline-menu-item-select"
69- itemRenderer = { ( item , { modifiers, handleClick } ) => (
70- < MenuItem
71- key = { item }
72- text = { item }
73- active = { modifiers . active }
74- onClick = { handleClick }
75- />
76- ) }
7781 itemPredicate = { itemPredicate }
7882 items = { items }
83+ activeItem = { currentValue as T }
84+ filterable = { shouldFilter }
85+ // transformItem={(item) => formatDisplayText(String(item))}
7986 onItemSelect = { ( s ) => {
8087 updateBlock ( {
8188 text : `${ attributeName } :: ${ s } ` ,
8289 uid,
8390 } ) ;
91+ setIsOpen ( false ) ;
92+ } }
93+ popoverProps = { {
94+ isOpen,
95+ onClose : ( ) => setIsOpen ( false ) ,
8496 } }
85- activeItem = { currentValue as T }
86- // onActiveItemChange={} // TODO: get this working for keyboard support
87- filterable = { filterable }
8897 >
89- < Button
90- className = "roamjs-attribute-select-button p-0 ml-1"
91- icon = "chevron-down"
92- style = { { minHeight : 15 , minWidth : 20 } }
93- intent = "primary"
94- minimal
95- onClick = { ( ) => setIsOpen ( true ) }
96- />
97- </ AttributeSelect >
98+ { ( ) => (
99+ < Button
100+ className = "roamjs-attribute-select-button p-0 ml-1"
101+ icon = "chevron-down"
102+ style = { { minHeight : 15 , minWidth : 20 } }
103+ intent = "primary"
104+ minimal
105+ onClick = { ( ) => setIsOpen ( true ) }
106+ />
107+ ) }
108+ </ MenuItemSelect >
98109 ) ;
99110} ;
100111
@@ -214,6 +225,7 @@ const AttributeButton = ({
214225 uid = { uid }
215226 currentValue = { currentValue }
216227 isOpen = { isOpen }
228+ filterable = { true }
217229 />
218230 ) }
219231 </ >
0 commit comments