mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +08:00
Command palette: auto close if other palette opens (#5192)
This commit is contained in:
parent
a637caf864
commit
53a314d946
|
@ -2130,6 +2130,11 @@ function CommandPalette(commandEnumerator, opts) {
|
||||||
this.renderAndBindElements();
|
this.renderAndBindElements();
|
||||||
this.hookEvents();
|
this.hookEvents();
|
||||||
Hotkeys.addHotkeyToHelpSheet(opts.toggleKey, opts.hotkeyDescription);
|
Hotkeys.addHotkeyToHelpSheet(opts.toggleKey, opts.hotkeyDescription);
|
||||||
|
|
||||||
|
if (!CommandPalette.instances) {
|
||||||
|
CommandPalette.instances = [];
|
||||||
|
}
|
||||||
|
CommandPalette.instances.push(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandPalette.prototype.hookEvents = function(){
|
CommandPalette.prototype.hookEvents = function(){
|
||||||
|
@ -2269,6 +2274,14 @@ CommandPalette.prototype.adjustScrollPosition = function(itemElement){
|
||||||
CommandPalette.prototype.toggleDisplay = function(forceState) {
|
CommandPalette.prototype.toggleDisplay = function(forceState) {
|
||||||
var isDisplayed = (this.elements.palette.style.display !== "none");
|
var isDisplayed = (this.elements.palette.style.display !== "none");
|
||||||
var tobeDisplayed = (forceState !== undefined) ? forceState : !isDisplayed;
|
var tobeDisplayed = (forceState !== undefined) ? forceState : !isDisplayed;
|
||||||
|
|
||||||
|
if (tobeDisplayed) {
|
||||||
|
// auto close other command palettes
|
||||||
|
CommandPalette.instances.forEach(function(instance){
|
||||||
|
instance.elements.palette.style.display = "none";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.elements.palette.style.display = tobeDisplayed ? "" : "none";
|
this.elements.palette.style.display = tobeDisplayed ? "" : "none";
|
||||||
if (tobeDisplayed) {
|
if (tobeDisplayed) {
|
||||||
this.elements.input.value = "";
|
this.elements.input.value = "";
|
||||||
|
@ -2276,6 +2289,7 @@ CommandPalette.prototype.toggleDisplay = function(forceState) {
|
||||||
this.applyFilter();
|
this.applyFilter();
|
||||||
this.selectFirst();
|
this.selectFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CommandPalette.prototype.getCommandByElement = function(element) {
|
CommandPalette.prototype.getCommandByElement = function(element) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user