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

a listbox doesn't update selectedItem for a specific item at the first time

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 8.6.2
    • 8.6.1, 8.6.0.1
    • None
    • Security Level: Jimmy
    • None
    • ZK 8.6.2 S2

      Steps to Reproduce

      1. run the attached zul
      a listbox with select mold
      2. select "Item 2"

      Simplified Step

      <zk>
        	<zscript><![CDATA[
            public class TestVM {
                List list = Arrays.asList(new String[] {"Group", "Item 1", "Item 2", "Item 3", "Item 4"});
                String selected = "Item 1";
                public List getList() { return list; }
                public String getSelected() { return selected; }
                public void setSelected(String selected) { this.selected = selected; }
            }
            TestVM viewModel = new TestVM();
          ]]></zscript>
      	<div viewModel="@id('vm') @init(viewModel)">
      		<listbox mold="select" rows="1" model="@init(vm.list)" selectedItem="@bind(vm.selected)">
      			<template name="model" >
                    <listgroup if="${each eq 'Group'}" label="${each}" />
                    <listitem unless="${each eq 'Group'}" label="${each}"/>
      			</template>
      		</listbox>
      		Selected Item:
      		<label value="@load(vm.selected)" />
          </div>
      </zk>
      
      

      http://zkfiddle.org/sample/1i46ano/3-ZK-4295-simplified

      Current Result

      • the selected item doesn't change
      • zk au doesn't fire

      Expected Result

      the selected item changes

      Debug Information

      1. if you select another item at the first time, it works as expected
      2. if you select "Item 2" after the second time. For example, select "Item 3" first, then "Item 2", it works as expected.
      3. if I remove <listgroup>, this issue doesn't happen.
      4. <zk switch> also produces the bug

      Workaround

      replace <listgroup> with <listitem disabled="true"/>

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

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day, 4 hours
                1d 4h
                Remaining:
                Time Spent - 4 hours Remaining Estimate - 1 day
                1d
                Logged:
                Time Spent - 4 hours Remaining Estimate - 1 day
                4h