Skip to content

Commit d1a296a

Browse files
authored
fix: sandbox not render another queries (#349) (#350)
* fix: sandbox not render another queries
1 parent 1375ffc commit d1a296a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/sandbox.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,18 @@ function Sandbox() {
124124
);
125125
}
126126

127+
function checkQuery(queries) {
128+
const suggestions = Object.values(queries).filter(Boolean);
129+
const suggestion = Object.values(queries).find(Boolean);
130+
131+
const anotherSuggestion = suggestions.find(
132+
(query) =>
133+
query?.queryName && !query.snippet?.startsWith('// sorry, I failed'),
134+
);
135+
136+
return anotherSuggestion ? anotherSuggestion : suggestion;
137+
}
138+
127139
function onSelectNode(node, { origin }) {
128140
// onSelectNode can be triggered after onMouseLeave has already been called.
129141
// This makes it impossible to clear hover state. That's why we maintain and
@@ -138,7 +150,8 @@ function onSelectNode(node, { origin }) {
138150
rootNode: state.rootNode,
139151
});
140152

141-
const suggestion = Object.values(queries).find(Boolean);
153+
const suggestion = checkQuery(queries);
154+
142155
if (!suggestion) {
143156
return;
144157
}

0 commit comments

Comments
 (0)