瀏覽代碼

fix bugs with resizing

Adam Shaw 6 年之前
父節點
當前提交
99b44b73b4

+ 2 - 7
packages/core/src/Calendar.tsx

@@ -432,7 +432,6 @@ export default class Calendar {
     let specialUpdates = {}
     let specialUpdates = {}
     let oldDateEnv = this.dateEnv // do this before onOptionsChange
     let oldDateEnv = this.dateEnv // do this before onOptionsChange
     let isTimeZoneDirty = false
     let isTimeZoneDirty = false
-    let isSizeDirty = false
     let anyDifficultOptions = Boolean(removals.length)
     let anyDifficultOptions = Boolean(removals.length)
 
 
     for (let name in updates) {
     for (let name in updates) {
@@ -444,12 +443,10 @@ export default class Calendar {
     }
     }
 
 
     for (let name in normalUpdates) {
     for (let name in normalUpdates) {
-      if (/^(height|contentHeight|aspectRatio)$/.test(name)) {
-        isSizeDirty = true
-      } else if (/^(defaultDate|defaultView)$/.test(name)) {
+      if (/^(defaultDate|defaultView)$/.test(name)) {
         // can't change date this way. use gotoDate instead
         // can't change date this way. use gotoDate instead
       } else {
       } else {
-        anyDifficultOptions = true
+        anyDifficultOptions = true // I guess all options are "difficult" ?
 
 
         if (name === 'timeZone') {
         if (name === 'timeZone') {
           isTimeZoneDirty = true
           isTimeZoneDirty = true
@@ -483,8 +480,6 @@ export default class Calendar {
           viewType: this.state.viewType
           viewType: this.state.viewType
         })
         })
 
 
-      } else if (isSizeDirty) {
-        this.updateSize()
       }
       }
 
 
       // special updates
       // special updates

+ 3 - 4
packages/core/src/scrollgrid/Scroller.tsx

@@ -59,7 +59,7 @@ export default class Scroller extends BaseComponent<ScrollerProps> implements Sc
 
 
 
 
   componentDidUpdate(prevProps: ScrollerProps) {
   componentDidUpdate(prevProps: ScrollerProps) {
-    this.handleSizing()
+    this.handleSizing(prevProps.overflowY !== this.props.overflowY)
   }
   }
 
 
 
 
@@ -68,7 +68,7 @@ export default class Scroller extends BaseComponent<ScrollerProps> implements Sc
   }
   }
 
 
 
 
-  handleSizing = () => { // SIZING HACKS
+  handleSizing = (overflowYChanged?: boolean) => { // SIZING HACKS
     let rootEl = this.el
     let rootEl = this.el
     let childNodes = rootEl.childNodes
     let childNodes = rootEl.childNodes
 
 
@@ -84,8 +84,7 @@ export default class Scroller extends BaseComponent<ScrollerProps> implements Sc
 
 
         // for Safari bug, change in y-scrollbars wouldn't change table width (with 100% width)
         // for Safari bug, change in y-scrollbars wouldn't change table width (with 100% width)
         // won't do anything if the <col>s already have an opinion about width
         // won't do anything if the <col>s already have an opinion about width
-        // important not do when no scrollbars. was getting false positives.
-        if (this.props.overflowY !== 'hidden') {
+        if (overflowYChanged) {
           tableEl.style.width = rootEl.clientWidth + 'px'
           tableEl.style.width = rootEl.clientWidth + 'px'
         }
         }
       }
       }

+ 15 - 9
packages/core/src/scrollgrid/SimpleScrollGrid.tsx

@@ -109,14 +109,17 @@ export default class SimpleScrollGrid extends BaseComponent<SimpleScrollGridProp
     } else {
     } else {
       return (
       return (
         <td class={getChunkClassNames(sectionConfig, chunkConfig, this.context)} ref={chunkConfig.elRef}>
         <td class={getChunkClassNames(sectionConfig, chunkConfig, this.context)} ref={chunkConfig.elRef}>
-          <Scroller
-            ref={this.scrollerRefs.createRef(sectionI)}
-            elRef={this.scrollerElRefs.createRef(sectionI, chunkConfig)}
-            overflowY={overflowY}
-            overflowX='hidden'
-            maxHeight={sectionConfig.maxHeight}
-            vGrow={vGrow}
-          >{content}</Scroller>
+          <div>{/* when we didn't have this, preact was recycling the ref, and removing it
+            (not not adding it back yet) before recomputing the scrollbar-forcing  */}
+            <Scroller
+              ref={this.scrollerRefs.createRef(sectionI)}
+              elRef={this.scrollerElRefs.createRef(sectionI, chunkConfig)}
+              overflowY={overflowY}
+              overflowX='hidden'
+              maxHeight={sectionConfig.maxHeight}
+              vGrow={vGrow}
+            >{content}</Scroller>
+          </div>
         </td>
         </td>
       )
       )
     }
     }
@@ -148,7 +151,10 @@ export default class SimpleScrollGrid extends BaseComponent<SimpleScrollGridProp
 
 
   handleSizing = () => {
   handleSizing = () => {
 
 
-    if (hasShrinkWidth(this.props.cols)) {
+    if (
+      !this.props.forPrint && // temporary? do in ScrollGrid?
+      hasShrinkWidth(this.props.cols)
+    ) {
       this.setState({
       this.setState({
         shrinkWidth: computeShrinkWidth(this.scrollerElRefs.getAll())
         shrinkWidth: computeShrinkWidth(this.scrollerElRefs.getAll())
       })
       })