Browse Source

Bug fix: setting relative sizes did not work on the first try.

Afshin Darian 7 năm trước cách đây
mục cha
commit
3b9eb7dcca
1 tập tin đã thay đổi với 17 bổ sung15 xóa
  1. 17 15
      packages/settingeditor-extension/src/settingeditor.ts

+ 17 - 15
packages/settingeditor-extension/src/settingeditor.ts

@@ -182,19 +182,14 @@ class SettingEditor extends Widget {
    */
   protected onAfterAttach(msg: Message): void {
     super.onAfterAttach(msg);
-
-    // Allow the message queue (which includes fit requests that might disrupt
-    // setting relative sizes) to clear before setting sizes.
-    requestAnimationFrame(() => {
-      this._panel.hide();
-      this._fetchState().then(() => {
-        this._panel.show();
-        this._setState();
-      }).catch(reason => {
-        console.error('Fetching setting editor state failed', reason);
-        this._panel.show();
-        this._setState();
-      });
+    this._panel.hide();
+    this._fetchState().then(() => {
+      this._panel.show();
+      this._setState();
+    }).catch(reason => {
+      console.error('Fetching setting editor state failed', reason);
+      this._panel.show();
+      this._setState();
     });
   }
 
@@ -266,8 +261,15 @@ class SettingEditor extends Widget {
    * Set the layout sizes.
    */
   private _setLayout(): void {
-    this._editor.state = this._state.container;
-    this._panel.setRelativeSizes(this._state.sizes);
+    const editor = this._editor;
+    const panel = this._panel;
+    const state = this._state;
+
+    editor.state = state.container;
+
+    // Allow the message queue (which includes fit requests that might disrupt
+    // setting relative sizes) to clear before setting sizes.
+    requestAnimationFrame(() => { panel.setRelativeSizes(state.sizes); });
   }
 
   /**