diff --git a/resources/web/dialog/SpeedDial/speeddial.js b/resources/web/dialog/SpeedDial/speeddial.js index ee63c1c204..65f64b4399 100644 --- a/resources/web/dialog/SpeedDial/speeddial.js +++ b/resources/web/dialog/SpeedDial/speeddial.js @@ -56,9 +56,13 @@ function shouldRenderActionList(query) { // Resolve the selection cursor {zone,i} to the action id it points at: fav zone indexes the // visible favourites, list zone the filtered actions. Pure so runSelected() shares one lookup. -function selectedActionId(sel, actions, favIds) { +function selectedActionId(sel, actions, favIds, query) { if (sel.zone === "fav") return favIds[sel.i]; + // why: search-first keeps the list blank until the user types; an empty query still + // filters to ALL actions, so without this gate Enter fires an action never shown. + if (!shouldRenderActionList(query)) + return null; var a = actions[sel.i]; return a && a.id; } @@ -444,7 +448,7 @@ function run(a) { } function runSelected() { - var id = selectedActionId(sel, filterActions(ACTIONS, query), currentVisibleFavs()); + var id = selectedActionId(sel, filterActions(ACTIONS, query), currentVisibleFavs(), query); if (id) run(byId(id)); } diff --git a/resources/web/dialog/SpeedDial/speeddial.test.js b/resources/web/dialog/SpeedDial/speeddial.test.js index e29b34f476..05c1e69c23 100644 --- a/resources/web/dialog/SpeedDial/speeddial.test.js +++ b/resources/web/dialog/SpeedDial/speeddial.test.js @@ -26,4 +26,20 @@ assert.equal(ctx.shouldRenderActionList(""), false, "an empty search keeps the a assert.equal(ctx.shouldRenderActionList(" "), false, "whitespace-only search keeps the action list hidden"); assert.equal(ctx.shouldRenderActionList("r"), true, "typing starts rendering matching actions"); +assert.equal( + ctx.selectedActionId({ zone: "list", i: 0 }, duplicateActions, [], ""), + null, + "Enter with an empty query must not resolve to an action the blank list never showed" +); +assert.equal( + ctx.selectedActionId({ zone: "list", i: 0 }, duplicateActions, [], "rep"), + "0123456789abcdef", + "a typed query resolves the list selection" +); +assert.equal( + ctx.selectedActionId({ zone: "fav", i: 0 }, duplicateActions, ["fedcba9876543210"], ""), + "fedcba9876543210", + "favourites stay runnable with an empty query - the fav bar is always visible" +); + console.log("ok");