Skip to content

Commit

Permalink
Disable replaceSelection if nothing is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonWeill committed Jun 30, 2023
1 parent c772ac1 commit ecd0610
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/jupyter-ai/src/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ function ChatBody({
);
}

// If there is no selection, the "replace selection" button will not be
// visible; treat it as disabled
const hasSelection = !!selection?.text;
return (
<>
<ScrollContainer sx={{ flexGrow: 1 }}>
Expand All @@ -154,12 +157,12 @@ function ChatBody({
value={input}
onChange={setInput}
onSend={onSend}
hasSelection={!!selection?.text}
hasSelection={hasSelection}
includeSelection={includeSelection}
toggleIncludeSelection={() =>
setIncludeSelection(includeSelection => !includeSelection)
}
replaceSelection={replaceSelection}
replaceSelection={hasSelection && replaceSelection}
toggleReplaceSelection={() =>
setReplaceSelection(replaceSelection => !replaceSelection)
}
Expand Down

0 comments on commit ecd0610

Please sign in to comment.