-
FEATURED COMPONENTS
First time here? Check out the FAQ!
When I select multiple items in Listbox by holding the shift key, the wrong items are getting marked.
Some days ago this was working fine but now all out of sudden this weird behavior started occurring. Is it a ZK bug?
See the problem in action: http://www.youtube.com/watch?v=wOVMo519KQA
I tested on a simple zk listbox in 508, no such issue.
which zk do you use?
could you provide a simple reproducible code and steps? then we can judge it is a bug or not
Hi,
I am using 5.0.8 as well. That problem existed in 5.0.7.1 too.
You're right, with a "plain" listbox the problem doesn't occur.
It seems like the listbox is conflicting with something else in my application. Unfortunately it's very difficult for me to isolate the code to create some sample code since it's a pretty big project with many dependencies.
However, I once already experienced this problem and that was when I attached a listener for key press events for each Listitem (was checking if the user was holding the Ctrl or shift key when he clicked on an item).
After removing the listener the problem was gone.
Now some weeks later, I still don't have registered such an event listener but all out of sudden the problem is back again.
Does this make any sense to you?
could you provide some code snippet of that listener? the event it listens, and the code it handles
I found out what the problem is!
Once I click the first time on a listitem, it gets selected and I show a preview of the email in the box below the listbox (see video).
If I do that, the listbox looses focus.
If I now hold shift and click another listitem, the weird behavior occurs.
If I click the already selected listitem (before holding shift), the listbox gets back focus and the problem does not occur.
Sounds like a ZK bug to me.
No idea?
I already tried to manually re-set focus by calling listbox.setFocus(true) but that doesn't do the trick since the "preview" box on the bottom seems to get focus after the call to listbox.setFocus(true) :-(
I try to simplify your issue, however, maybe it is too simple, it works fine in zksandbox, 5.0.8 env.
could you try to provide some code that close your real case?
<zk> <zscript> ListModel strset = new org.zkoss.zksandbox.grid.FakeListModel(20000); </zscript> <listbox id="list" width="200px" rows="10" model="${strset}" onSelect="btn.setFocus(true)" multiple="true"> <listhead> <listheader label="Load on Demend" sort="auto"/> </listhead> </listbox> <button id="btn" label="focus"/> </zk>
Damn, you're right!
I just created a new ZK project to replicate the issue but I didn't succeed :-(
That's very strange.
In my original code, when I remove the one line which starts the email's preview, everything works smoothly but with that line, Listbox starts this weird behavior. I'll then have to RE-CLICK the selected item to given the Listbox focus and then multiple selection via the shift key works.. I don't get it.
I finally found the source for the problem and I was able to reproduce it!
Download this ZK project and run it: http://dl.dropbox.com/u/17844821/zeug/ListboxBug.zip
To reproduce, follow these steps EXACTLY:
1. Click one of the items in the listbox
2. A second listbox should appear at the bottom
3. Hold shift and click another list item in the UPPER listbox
4. The "bug" should appear
I was also able to find the function which causes this problem. It's the method "invalidateAll()" in src/com/Controller.java.
If you comment it out, the Listbox behavior returns to normal.
Unfortunately, in my real application, I need this method to fix a UI issue.
ok, the problem is now reproducible
<zk> <zscript> ListModel strset = new org.zkoss.zksandbox.grid.FakeListModel(20000); </zscript> <listbox id="list" width="200px" rows="10" model="${strset}" onSelect="list.invalidate()" multiple="true"> <listhead> <listheader label="Load on Demend" sort="auto"/> </listhead> </listbox> <button id="btn" label="focus"/> </zk>
bug posted, http://tracker.zkoss.org/browse/ZK-418
Asked: 2011-09-06 08:23:55 +0800
Seen: 1,023 times
Last updated: Sep 14 '11