Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Backspace in composer custom prompt closes menu #505

Merged
merged 1 commit into from Mar 4, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -154,8 +154,11 @@ export default class AiHelperContextMenu extends Component {
if (event.key === "Escape") {
return this.closeContextMenu();
}

if (event.key === "Backspace" && this.selectedText) {
if (
event.key === "Backspace" &&
this.selectedText &&
this.menuState === this.CONTEXT_MENU_STATES.triggers
) {
return this.closeContextMenu();
}
}
Expand Down
16 changes: 16 additions & 0 deletions spec/system/ai_helper/ai_composer_helper_spec.rb
Expand Up @@ -65,6 +65,13 @@ def trigger_context_menu(content)
expect(ai_helper_context_menu).to have_no_context_menu
end

it "closes the context menu when selected text is deleted" do
trigger_context_menu(input)
expect(ai_helper_context_menu).to have_context_menu
page.send_keys(:backspace)
expect(ai_helper_context_menu).to have_no_context_menu
end

context "when using custom prompt" do
let(:mode) { CompletionPrompt::CUSTOM_PROMPT }

Expand Down Expand Up @@ -98,6 +105,15 @@ def trigger_context_menu(content)
expect(composer.composer_input.value).to eq(custom_prompt_response)
end
end

it "should not close the context menu if backspace is pressed" do
trigger_context_menu(input)
ai_helper_context_menu.click_ai_button
expect(ai_helper_context_menu).to have_context_menu
ai_helper_context_menu.fill_custom_prompt(custom_prompt_input)
page.find(".ai-custom-prompt__input").send_keys(:backspace)
expect(ai_helper_context_menu).to have_context_menu
end
end

context "when not a member of custom prompt group" do
Expand Down