Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion devtools/src/devtools/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Panel() {
setResult(result);
});

if (action.updateEditor !== false) {
if (action.origin !== 'EDITOR') {
editor.current.setValue(action.query);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/components/MarkupEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function MarkupEditor({ markup, dispatch }) {
dispatch({
type: 'SET_MARKUP',
markup,
updateEditor: false,
origin: 'EDITOR',
immediate: origin === 'user',
}),
[dispatch],
Expand Down
6 changes: 5 additions & 1 deletion src/components/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ function Preview({ markup, variant, forwardedRef, dispatch }) {
}

case 'SELECT_NODE': {
dispatch({ type: 'SET_QUERY', query: suggestion.snippet });
dispatch({
type: 'SET_QUERY',
query: suggestion.snippet,
origin: 'SANDBOX',
});
break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/QueryEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function QueryEditor(props) {
dispatch({
type: 'SET_QUERY',
query,
updateEditor: false,
origin: 'EDITOR',
immediate: origin === 'user',
}),
[dispatch],
Expand Down
8 changes: 5 additions & 3 deletions src/hooks/usePlayground.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function reducer(state, action, exec) {
}

case 'SET_MARKUP': {
if (action.updateEditor !== false) {
if (action.origin !== 'EDITOR') {
exec({ type: 'UPDATE_EDITOR', editor: 'markup' });
}

Expand All @@ -66,11 +66,13 @@ function reducer(state, action, exec) {
}

case 'SET_QUERY': {
if (action.updateEditor !== false) {
if (action.origin !== 'EDITOR') {
exec({ type: 'UPDATE_EDITOR', editor: 'query' });
}

exec({ type: 'UPDATE_SANDBOX', immediate });
if (action.origin !== 'SANDBOX') {
exec({ type: 'UPDATE_SANDBOX', immediate });
}

return {
...state,
Expand Down
6 changes: 6 additions & 0 deletions src/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ function onSelectNode(node, { origin }) {
cssPath: cssPath(node, true).toString(),
};

if (action.type === 'SELECT_NODE') {
// optimistically update the highlighted node
state.queriedNodes = [node];
state.highlighter.highlight({ nodes: state.queriedNodes });
}

postMessage(action);
}

Expand Down