Skip to content

Commit

Permalink
Merge pull request #742 from ru8vup4wei/B80-ZK-3411
Browse files Browse the repository at this point in the history
Fixed ZK-3411: a component's height doesn't fill up its parent with v…
  • Loading branch information
DevChu committed Dec 2, 2016
2 parents 7153c00 + 8e6aeae commit 7089ac0
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 19 deletions.
51 changes: 32 additions & 19 deletions zk/src/archive/web/js/zk/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ zFlex = { //static methods
hgh = psz.height,
wdh = psz.width,
c = p.firstChild,
scrWdh;

scrWdh,
vflexsRe = [];
// Bug 3185686, B50-ZK-452
if (zkp.hasVScroll()) //with vertical scrollbar
wdh -= (scrWdh = jq.scrollbarWidth());
Expand Down Expand Up @@ -395,6 +395,7 @@ zFlex = { //static methods
hgh -= zFlex.fixMinFlex(cwgt, c, 'h');
} else {
vflexs.push(cwgt);
vflexsRe.push(cwgt);
vflexsz += cwgt._nvflex;
}
} else if (!cwgt || !cwgt.isExcludedVflex_()) {
Expand All @@ -405,25 +406,30 @@ zFlex = { //static methods
pretxt = false;
}
}


// ZK-3411: use local function for setting up height
var setHghForVflexChild = function (vfxs, h, lsz) {
for (var j = vfxs.length - 1; j > 0; --j) {
var cwgt = vfxs.shift(),
vsz = cwgt.isExcludedVflex_() ? h : (cwgt._nvflex * h / vflexsz) | 0; //cast to integer
cwgt.setFlexSize_({height: vsz});
cwgt._vflexsz = vsz;
if (!cwgt.isExcludedVflex_())
lsz -= vsz;
}
//last one with vflex
if (vfxs.length) {
var cwgt = vfxs.shift();
cwgt.setFlexSize_({height: lsz});
cwgt._vflexsz = lsz;
}
};

//setup the height for the vflex child
//avoid floating number calculation error(TODO: shall distribute error evenly)
var lastsz = hgh = Math.max(hgh, 0);
for (var j = vflexs.length - 1; j > 0; --j) {
var cwgt = vflexs.shift(),
vsz = cwgt.isExcludedVflex_() ? hgh :
(cwgt._nvflex * hgh / vflexsz) | 0; //cast to integer
cwgt.setFlexSize_({height: vsz});
cwgt._vflexsz = vsz;
if (!cwgt.isExcludedVflex_())
lastsz -= vsz;
}
//last one with vflex
if (vflexs.length) {
var cwgt = vflexs.shift();
cwgt.setFlexSize_({height: lastsz});
cwgt._vflexsz = lastsz;
}
setHghForVflexChild(vflexs, hgh, lastsz);

//3042306: H/Vflex in IE6 can't shrink; others cause scrollbar space
//vertical scrollbar might disappear after height was set
var newpsz = wgt.getParentSize_(p);
Expand All @@ -447,7 +453,14 @@ zFlex = { //static methods
cwgt.setFlexSize_({width: lastsz});
cwgt._hflexsz = lastsz;
}


// ZK-3411: height need to be reset if the horizontal scrollbar disappeared
if (newpsz.height > psz.height) { //horizontal scrollbar disappeared
hgh += (newpsz.height - psz.height);
lastsz = hgh = Math.max(hgh, 0);
setHghForVflexChild(vflexsRe, hgh, lastsz);
}

//notify parent widget that all of its children with hflex/vflex is done.
wgt.parent.afterChildrenFlex_(wgt);
wgt._flexFixed = false;
Expand Down
1 change: 1 addition & 0 deletions zkdoc/release-note
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ZK 8.0.4
ZK-3519: Inconsistent behavior in disabled input based controls
ZK-3342: Datebox today link date-format
ZK-3533: Message code not found in msgzul
ZK-3411: a component's height doesn't fill up its parent with vflex="1" when there is a vertical scrollbar

* Upgrade Notes

Expand Down
51 changes: 51 additions & 0 deletions zktest/src/archive/test2/B80-ZK-3411.zul
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
B80-ZK-3411.zul
Purpose:
Description:
History:
Tue Nov 29 09:50:00 CST 2016, Created by Jack Wei
Copyright (C) 2016 Potix Corporation. All Rights Reserved.
-->
<zk>

<zscript><![CDATA[
ArrayList cols = new ArrayList();
for (int i = 0; i < 10; i++) {
cols.add("Column " + i);
}
ArrayList rows = new ArrayList();
for (int i = 0; i < 40; i++) {
rows.add("Row " + i);
}
]]>
</zscript>
<window hflex="1" vflex="1">
<grid hflex="1" vflex="1" span="true" style="background:#ddd">
<columns>
<column forEach="${cols}" hflex="min"><label value="${each}" /></column>
</columns>
<rows>
<!--<row forEach="${rows}"><label forEach="${cols}" value="Content content" /></row>-->
<row forEach="${rows}">
<label value="there" />
<label value="should not" />
<label value="have extra space" />
<label value="at bottom and right" />
<label value="between the grid" />
<label value="and the browser" />
<label value="since" />
<label value="hflex is 1" />
<label value="and" />
<label value="vflex is 1" />
</row>
</rows>
</grid>
</window>
</zk>
1 change: 1 addition & 0 deletions zktest/src/archive/test2/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2282,6 +2282,7 @@ B80-ZK-3505.zul=A,E,Caption,Tabindex,DefaultTabindex
##zats##B80-ZK-3519.zul=A,E,Input,disabled,click,onRightClick
##zats##B80-ZK-3342.zul=A,E,Datebox,Calendar,today,label
##zats##B80-ZK-3533.zul=A,E,Msgzul,i18n,panel,restore
B80-ZK-3411.zul=A,E,flex,onSize,scrollbar,Grid,resize

##
# Features - 3.0.x version
Expand Down

0 comments on commit 7089ac0

Please sign in to comment.