Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-2987

Going to the last page causes an empty-like listbox

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 7.0.7, 8.0.1
    • 8.0.0, 7.0.6.1, 6.5.8.1
    • None
    • Security Level: Jimmy
    • None
    • ZK 7.0.7

      steps to reproduce

      1. load the zul below
        <zk>
        	<zscript><![CDATA[
        		ListModelList items = new ListModelList();
        	    for(int i = 0; i <= 250; i++) {	    	
        	    	String label = "Item "+i;	    	
        	    	items.add(label);
        	    }
        	   //items.setMultiple(true);
        	   
        	   ListitemRenderer renderer = new ListitemRenderer(){
        	   	void render(Listitem item, Object data, int index){
        	   		item.appendChild(new Listcell());
        	   		Listcell cell = new Listcell();
        	   		Label label = new Label((String)data);
        	   		label.setMultiline(true);
        	   		label.setParent(cell);	   		
        	   		item.appendChild(cell);
        	   	}
        	   };
        	]]></zscript>
        	<borderlayout>
        		<center>
        			<listbox hflex="1" id="theListbox"  onPaging="self.focus()" mold="paging" pageSize="100" height="400px" pagingPosition="bottom" checkmark="true" multiple="true" model="${items}" itemRenderer="${renderer}">
        				<custom-attributes org.zkoss.zul.listbox.rod="true"/> 
        				<listhead>
        					<listheader/>
        					<listheader label="col"/>
        				</listhead>				
        			</listbox>
        		</center>
        	</borderlayout>
        </zk>
        

        or http://zkfiddle.org/sample/2n0dcer/3-empty-like-listbox

      2. scroll to show the last item in the 1st page
      3. go to the last page by clicking the paging control

      result

      an empty-like listbox, but there are actually 50 items.

      The scrollbar position is incorrect.

      Debug info

      1. remove onPaging="self.focus()" and this issue doesn't happen.
      2. After the issue happens, selecting an item will eliminate the issue.
      3. 7.0.0 ~ 7.0.4 don't have such issue.
      4. When the issue happen, z-focus-a's top position is too large, it should be 1555px
        <button id="d4KQ2-a" style="top: 2776px; left: 0px;" onclick="return false;" href="javascript:;" class="z-focus-a"></button>

      Workaround

      • (for 6.5.8.1) do not maintain scrolling position
        	<script><![CDATA[
        zk.afterLoad('zul.sel', function() {
        	var old = {};
        	zk.override(zul.sel.SelectWidget.prototype, old, {	                 
        		focus_: function (timeout) {
        			var btn;
        			if (btn = this.$n('a')) {
        				if (this._focusItem) {
        					for (var it = this.getBodyWidgetIterator(), w; (w = it.next());) 
        						if (this._isFocus(w)) {
        							w.focus_(timeout);
        							break;
        						}
        				}
        				this.focusA_(btn, timeout);
        				return true;
        			}
        			return false;
        		}
        	});
        });
        	]]>
        	</script>
        

            christopherszu christopherszu
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 6 hours, 30 minutes
                6h 30m