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: apply class to autocomplete popup for no suggestions state #5522

Merged
merged 15 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
4 changes: 3 additions & 1 deletion src/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ class Autocomplete {
];
this.completions = new FilteredList(completionsForEmpty);
this.openPopup(this.editor, prefix, keepPopupPosition);
this.popup.renderer.setStyle("ace_loading", false);
this.popup.renderer.setStyle("ace_loading", false);
this.popup.renderer.setStyle("ace_empty-message", true);
return;
}
return this.detach();
Expand All @@ -598,6 +599,7 @@ class Autocomplete {

this.openPopup(this.editor, prefix, keepPopupPosition);

this.popup.renderer.setStyle("ace_empty-message", false);
this.popup.renderer.setStyle("ace_loading", !finished);
}.bind(this));

Expand Down
31 changes: 31 additions & 0 deletions src/autocomplete_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"use strict";

var sendKey = require("./test/user").type;
var {buildDom} = require("./lib/dom");

Check warning on line 8 in src/autocomplete_test.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'buildDom' is assigned a value but never used
var ace = require("./ace");
var assert = require("./test/assertions");
var user = require("./test/user");
Expand Down Expand Up @@ -462,12 +462,43 @@
user.type("Ctrl-Space");
assert.equal(editor.completer.popup.isOpen, true);
assert.equal(editor.completer.popup.data[0].caption, emptyMessageText);
assert.ok(editor.completer.popup.renderer.container.classList.contains("ace_empty-message"));

user.type("Return");
assert.equal(editor.completer.popup.isOpen, false);

done();
},
"test: no empty message class if suggestions available": function(done) {
var editor = initEditor("");
var emptyMessageText = "No suggestions.";
var autocomplete = Autocomplete.for(editor);
autocomplete.emptyMessage = () => emptyMessageText;

editor.completers = [
{
getCompletions: function (editor, session, pos, prefix, callback) {
var completions = [
{
caption: "append",
value: "append"
}
];
callback(null, completions);
}
}
];

user.type("app");

// Open autocompletion via key-binding and verify no empty message class
user.type("Ctrl-Space");
assert.equal(editor.completer.popup.isOpen, true);
assert.equal(editor.completer.popup.data[0].caption, "append");
assert.ok(!editor.completer.popup.renderer.container.classList.contains("ace_empty-message"));

akoreman marked this conversation as resolved.
Show resolved Hide resolved
done();
},
"test: liveAutocompleteDelay": function(done) {
var editor = initEditor("hello world ");
editor.setOptions({
Expand Down
Loading