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

Do not change focus when opening a Treeitem

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Done
    • Affects Version/s: 8.0.3
    • Fix Version/s: 8.5.2
    • Component/s: None
    • Security Level: Jimmy
    • Labels:
      None

      Description

      steps to reproduce

      1. load the attached zul
      2. type ch in the textbox

      current result

      ZK moves the focus to Tree, so that users can't continue his typing

      debug info

      • when opening a treeitem, treeitem's setopen() enforce moving focus on its parent tree.
        zul.sel.Treeitem = zk.$extends(zul.sel.ItemWidget, {
        	_open: true,
        	$define: {
        		
        		
        		open: function (open, fromServer) {
                            ....
                           tree.focus();
                        }
        

        we can consider not moving the focus.

      • Maybe there is another use case that requires getting focus while opening, e.g. a user opens a treeitem by mouse clicking instead of API. Then we can differentiate 2 cases with fromServer flag.

      workaround

      		
      		zk.afterLoad('zul.sel', function() {
      		    var oldMethods = {};
      		    zk.override(zul.sel.Treeitem.prototype, oldMethods, {
      				setOpen: function (open, fromServer) {
      					var previouslyFocused = zk.Widget.$(jq(':focus'));
      					oldMethods.setOpen.apply(this, arguments);
      					if (previouslyFocused){
      					    previouslyFocused.focus();
                                             }
      				}		
      		    });
      		});
      

      debug info

      • moving focus is a general issue that we will face when implementing every widget. We should collect use cases and conclude a design rule
      • it's better to focus a tree in doClick (click event handler) instead of setOpen()
      1. treesearch.zul
        4 kB
        hawk
      1. searching.png
        31 kB

        Activity

        Hide
        JamesChu JamesChu added a comment -

        Ready since 2018/06/01

        Show
        JamesChu JamesChu added a comment - Ready since 2018/06/01

          People

          • Assignee:
            CharlesQiu CharlesQiu
            Reporter:
            hawk hawk
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1 day
              1d
              Remaining:
              Time Spent - 2 hours Remaining Estimate - 6 hours
              6h
              Logged:
              Time Spent - 2 hours Remaining Estimate - 6 hours
              2h