feat: update context and show suggestions on select

This commit is contained in:
Yunus M 2025-06-14 23:42:36 +05:30 committed by SagarRajput-7
parent b27901cd70
commit 51a7dae5d9

View File

@ -790,8 +790,20 @@ function QuerySearch(): JSX.Element {
}, [queryKeySuggestions]); }, [queryKeySuggestions]);
useEffect(() => { useEffect(() => {
if (!queryContext?.isInValue) return; if (!queryContext) return;
// Trigger suggestions based on context
if (editorRef.current) {
// Small delay to ensure the context is fully updated
setTimeout(() => {
if (editorRef.current) {
startCompletion(editorRef.current);
}
}, 50);
}
// Handle value suggestions for value context
if (queryContext.isInValue) {
const { keyToken, currentToken } = queryContext; const { keyToken, currentToken } = queryContext;
const key = keyToken || currentToken; const key = keyToken || currentToken;
@ -799,7 +811,7 @@ function QuerySearch(): JSX.Element {
if (key && key !== activeKey && !isLoadingSuggestions) { if (key && key !== activeKey && !isLoadingSuggestions) {
fetchValueSuggestions(key); fetchValueSuggestions(key);
} }
// Use only the specific properties of queryContext we need to avoid unnecessary renders }
}, [queryContext, activeKey, isLoadingSuggestions, fetchValueSuggestions]); }, [queryContext, activeKey, isLoadingSuggestions, fetchValueSuggestions]);
return ( return (
@ -964,7 +976,7 @@ function QuerySearch(): JSX.Element {
</Card> </Card>
)} )}
{/* {queryContext && ( {queryContext && (
<Card size="small" title="Current Context" className="query-context"> <Card size="small" title="Current Context" className="query-context">
<div className="context-details"> <div className="context-details">
<Space direction="vertical" size={4}> <Space direction="vertical" size={4}>
@ -1004,7 +1016,7 @@ function QuerySearch(): JSX.Element {
</Space> </Space>
</div> </div>
</Card> </Card>
)} */} )}
</div> </div>
); );
} }