Bug 1414447 - Use displayed definitions in toolbox component for kb nav. r=jryans

This commit is contained in:
Eitan Isaacson 2017-11-13 15:31:00 -05:00
Родитель cc97d12776
Коммит d567085ce1
2 изменённых файлов: 12 добавлений и 8 удалений

Просмотреть файл

@ -147,6 +147,10 @@ class ToolboxController extends Component {
this.updateButtonIds();
}
get panelDefinitions() {
return this.state.panelDefinitions;
}
setToolboxButtons(toolboxButtons) {
// Listen for updates of the checked attribute.
this.state.toolboxButtons.forEach(button => {

Просмотреть файл

@ -1925,12 +1925,11 @@ Toolbox.prototype = {
* Loads the tool next to the currently selected tool.
*/
selectNextTool: function () {
const index = this.panelDefinitions.findIndex(({id}) => id === this.currentToolId);
let definition = this.panelDefinitions[index + 1];
let definitions = this.component.panelDefinitions;
const index = definitions.findIndex(({id}) => id === this.currentToolId);
let definition = definitions[index + 1];
if (!definition) {
definition = index === -1
? this.panelDefinitions[0]
: this.optionsDefinition;
definition = index === -1 ? definitions[0] : this.optionsDefinition;
}
return this.selectTool(definition.id);
},
@ -1939,11 +1938,12 @@ Toolbox.prototype = {
* Loads the tool just left to the currently selected tool.
*/
selectPreviousTool: function () {
const index = this.panelDefinitions.findIndex(({id}) => id === this.currentToolId);
let definition = this.panelDefinitions[index - 1];
let definitions = this.component.panelDefinitions;
const index = definitions.findIndex(({id}) => id === this.currentToolId);
let definition = definitions[index - 1];
if (!definition) {
definition = index === -1
? this.panelDefinitions[this.panelDefinitions.length - 1]
? definitions[definitions.length - 1]
: this.optionsDefinition;
}
return this.selectTool(definition.id);