|
|
@ -13,9 +13,9 @@ import { DataLinkBuiltInVars, GrafanaTheme2, VariableOrigin, VariableSuggestion |
|
|
|
import { SlatePrism } from '../../slate-plugins'; |
|
|
|
import { SlatePrism } from '../../slate-plugins'; |
|
|
|
import { useStyles2 } from '../../themes'; |
|
|
|
import { useStyles2 } from '../../themes'; |
|
|
|
import { SCHEMA, makeValue } from '../../utils/slate'; |
|
|
|
import { SCHEMA, makeValue } from '../../utils/slate'; |
|
|
|
import CustomScrollbar from '../CustomScrollbar/CustomScrollbar'; |
|
|
|
|
|
|
|
import { getInputStyles } from '../Input/Input'; |
|
|
|
import { getInputStyles } from '../Input/Input'; |
|
|
|
import { Portal } from '../Portal/Portal'; |
|
|
|
import { Portal } from '../Portal/Portal'; |
|
|
|
|
|
|
|
import { ScrollContainer } from '../ScrollContainer/ScrollContainer'; |
|
|
|
|
|
|
|
|
|
|
|
import { DataLinkSuggestions } from './DataLinkSuggestions'; |
|
|
|
import { DataLinkSuggestions } from './DataLinkSuggestions'; |
|
|
|
import { SelectionReference } from './SelectionReference'; |
|
|
|
import { SelectionReference } from './SelectionReference'; |
|
|
@ -86,6 +86,11 @@ export const DataLinkInput = memo( |
|
|
|
const [linkUrl, setLinkUrl] = useState<Value>(makeValue(value)); |
|
|
|
const [linkUrl, setLinkUrl] = useState<Value>(makeValue(value)); |
|
|
|
const prevLinkUrl = usePrevious<Value>(linkUrl); |
|
|
|
const prevLinkUrl = usePrevious<Value>(linkUrl); |
|
|
|
const [scrollTop, setScrollTop] = useState(0); |
|
|
|
const [scrollTop, setScrollTop] = useState(0); |
|
|
|
|
|
|
|
const scrollRef = useRef<HTMLDivElement>(null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
scrollRef.current?.scrollTo(0, scrollTop); |
|
|
|
|
|
|
|
}, [scrollTop]); |
|
|
|
|
|
|
|
|
|
|
|
// the order of middleware is important!
|
|
|
|
// the order of middleware is important!
|
|
|
|
const middleware = [ |
|
|
|
const middleware = [ |
|
|
@ -208,10 +213,10 @@ export const DataLinkInput = memo( |
|
|
|
{showingSuggestions && ( |
|
|
|
{showingSuggestions && ( |
|
|
|
<Portal> |
|
|
|
<Portal> |
|
|
|
<div ref={refs.setFloating} style={floatingStyles}> |
|
|
|
<div ref={refs.setFloating} style={floatingStyles}> |
|
|
|
<CustomScrollbar |
|
|
|
<ScrollContainer |
|
|
|
scrollTop={scrollTop} |
|
|
|
maxHeight="300px" |
|
|
|
autoHeightMax="300px" |
|
|
|
ref={scrollRef} |
|
|
|
setScrollTop={({ scrollTop }) => setScrollTop(scrollTop)} |
|
|
|
onScroll={(event) => setScrollTop(event.currentTarget.scrollTop)} |
|
|
|
> |
|
|
|
> |
|
|
|
<DataLinkSuggestions |
|
|
|
<DataLinkSuggestions |
|
|
|
activeRef={activeRef} |
|
|
|
activeRef={activeRef} |
|
|
@ -220,7 +225,7 @@ export const DataLinkInput = memo( |
|
|
|
onClose={() => setShowingSuggestions(false)} |
|
|
|
onClose={() => setShowingSuggestions(false)} |
|
|
|
activeIndex={suggestionsIndex} |
|
|
|
activeIndex={suggestionsIndex} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</CustomScrollbar> |
|
|
|
</ScrollContainer> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</Portal> |
|
|
|
</Portal> |
|
|
|
)} |
|
|
|
)} |
|
|
|