Bug 1396633 - Prevent updating toolbox react component until it is ready to be displayed. r=?
MozReview-Commit-ID: 5gOAq7mRygf
--- a/devtools/client/framework/components/toolbox-controller.js
+++ b/devtools/client/framework/components/toolbox-controller.js
@@ -67,29 +67,36 @@ module.exports = createClass({
updateFocusedButton() {
this.setFocusedButton(this.state.focusedButton);
},
setFocusedButton(focusedButton) {
const {buttonIds} = this.state;
- this.setState({
- focusedButton: focusedButton && buttonIds.includes(focusedButton)
+ focusedButton = focusedButton && buttonIds.includes(focusedButton)
? focusedButton
- : buttonIds[0]
- });
+ : buttonIds[0];
+ if (this.state.focusedButton !== focusedButton) {
+ this.setState({
+ focusedButton
+ });
+ }
},
setCurrentToolId(currentToolId) {
this.setState({currentToolId});
// Also set the currently focused button to this tool.
this.setFocusedButton(currentToolId);
},
+ shouldComponentUpdate() {
+ return this.state.canRender;
+ },
+
setCanRender() {
this.setState({ canRender: true });
this.updateButtonIds();
},
setOptionsPanel(optionsPanel) {
this.setState({ optionsPanel });
this.updateButtonIds();
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -490,17 +490,19 @@ Toolbox.prototype = {
// (bug 1072764).
let toolDef = gDevTools.getToolDefinition(this._defaultToolId);
if (!toolDef || !toolDef.isTargetSupported(this._target)) {
this._defaultToolId = "webconsole";
}
// Start rendering the toolbox toolbar before selecting the tool, as the tools
// can take a few hundred milliseconds seconds to start up.
- this.component.setCanRender();
+ buttonsPromise.then(() => {
+ this.component.setCanRender();
+ });
yield this.selectTool(this._defaultToolId);
// Wait until the original tool is selected so that the split
// console input will receive focus.
let splitConsolePromise = promise.resolve();
if (Services.prefs.getBoolPref(SPLITCONSOLE_ENABLED_PREF)) {
splitConsolePromise = this.openSplitConsole();