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

[Console] Fix wrong autosugest type #189496

Closed

Conversation

sabarasaba
Copy link
Member

@sabarasaba sabarasaba commented Jul 30, 2024

Fixes https://github.com//elastic/kibana/issues/186767

Summary

Fix wrongly returned method type for autosuggest method when unvalid line is passed

Steps to reproduce:

  1. Go to Kibana > Dev Tools > Console.
  2. Type in " (a double quote) at a blank line.

@sabarasaba sabarasaba added Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting v8.16.0 labels Jul 30, 2024
@sabarasaba sabarasaba self-assigned this Jul 30, 2024
@sabarasaba
Copy link
Member Author

/ci

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
console 457.4KB 457.4KB +18.0B

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @sabarasaba

@sabarasaba sabarasaba marked this pull request as ready for review July 30, 2024 13:17
@sabarasaba sabarasaba requested a review from a team as a code owner July 30, 2024 13:17
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-management (Team:Kibana Management)

@yuliacech yuliacech self-requested a review August 1, 2024 08:20
@@ -356,7 +356,7 @@ export class MonacoEditorActionsProvider {
});
const lineTokens = getLineTokens(lineContent);
// if there is 1 or fewer tokens, suggest method
if (lineTokens.length <= 1) {
if (lineTokens.length <= 1 && !shouldTriggerSuggestions(lineContent)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the helper function shouldTriggerSuggestions is a bit confusing here, it is used to check the line content if the suggestions should be triggered manually after a specific keybord event, for example backspace, as opposed to the automatic suggestions after "trigger characters".
The function getAutocompleteType here is used when the suggestions are triggered (automatic or manually) to decide for which of 4 item types to look for suggestions.
For this case I would recommend creating a separate helper or a reg ex, probably one to check that the line is either empty or have a character like g or p or maybe allow letters/numbers but not punctuation.

Copy link
Contributor

@yuliacech yuliacech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for fixing this bug, @sabarasaba!
I left a comment in the code about creating a separate check for this case, wdyt?

@sabarasaba sabarasaba closed this Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Console Dev Tools Console Feature release_note:skip Skip the PR/issue when compiling release notes Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants