mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
🐜 Card Menu Default State Enter Action (#600)
closes https://github.com/TryGhost/Ghost/issues/8196 The default state of both the '/' and '+' card menus is a selection of -1, this ensure that the active tool prompt isn't shown until the user presses an arrow key for keyboard selection. However -1 isn't a valid tool id so when pressing enter without selecting a tool the user will cause an error. This update ensures that the selected tool is the first tool available even if the selection is in fact -1.
This commit is contained in:
parent
c412d6e6f9
commit
848eda5656
2 changed files with 8 additions and 0 deletions
|
@ -51,6 +51,10 @@ export default Component.extend({
|
|||
this.set('selectedTool', selectedTool);
|
||||
selectedTool.selected = true;
|
||||
}
|
||||
} else {
|
||||
// even if the range is out of bounds (as in the starting state where the selection prompt is not shown)
|
||||
// we still need a selected item for the enter key.
|
||||
this.set('selectedTool', tools[0]);
|
||||
}
|
||||
return tools;
|
||||
}),
|
||||
|
|
|
@ -47,6 +47,10 @@ export default Component.extend({
|
|||
this.set('selectedTool', selectedTool);
|
||||
selectedTool.selected = true;
|
||||
}
|
||||
} else {
|
||||
// even if the range is out of bounds (as in the starting state where the selection prompt is not shown)
|
||||
// we still need a selected item for the enter key.
|
||||
this.set('selectedTool', tools[0]);
|
||||
}
|
||||
|
||||
return tools;
|
||||
|
|
Loading…
Add table
Reference in a new issue