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

missing safety checks on shift-ctrl selection on listbox

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 9.6.0.1
    • Fix Version/s: 9.6.1
    • Component/s: None
    • Security Level: Jimmy
    • Labels:
      None

      Description

      Steps to Reproduce

      https://zkfiddle.org/sample/2pvqgk0/18-Another-new-ZK-fiddle

      Run fiddle

      Select last Listitem

      Click button (delete last item)

      Shift+Click any Listitem

       

      Current Result

      Error: Index: 6, Size: 6

      Expected Result

      no error

      Debug Information

      caused by the Listbox._selectUpto function (from SelectWidget)

      https://github.com/zkoss/zk/blob/c787afdb2caee30df173da7fa45e00d2c658df08/zul/src/archive/web/js/zul/sel/SelectWidget.js#L878

       

      this._lastSelectedItem is not deleted from Listbox when listitem is removed, Listbox tries to use a non-existing index

      Workaround

      (see fiddle, commented out)

       

      Secondary issue, related to main issue

      If there is no selected element (due to component just having been rendered, and no selection triggered), doing shift+click on an item will select all items from index 0 to target  (see 2nd listbox with selected items content filled onSelect)

      However, only the targeted Listitem is marked as selected.

      (This is due to the same line of code as the main issue, if no bounding item is found)

        Attachments

          Activity

            People

            Assignee:
            jumperchen jumperchen
            Reporter:
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: