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

Menubar ignore menuitem margin when calculating scrollable status.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.0.2
    • 8.0.1
    • None
    • Security Level: Jimmy
    • None
    • ZK 8.0.2 S1

      In zul.menu.Menubar._checkScrolling method.

      The menubar calculate its scrollable status based on the total size of its children:

      		for (var i = childs.length; i-- ;)
      			totalWidth += childs[i].offsetWidth;
      

      However, this doesn't account for margins. Menuitems receive default margin of 4px (left+right), as the default style contains:

      .z-menubar-horizontal li {
          margin: 0 2px;
      

      This cause the calculated totalWidth to be nbChildren * 4px shorter that the actual displayed width. This in turn causes scroll display to not be triggered while the menu bar is smaller than the actual width but bigger that the calculated total width.

      Reproduce with:

      <zk>
      	<div hflex="1">
      		<menubar scrollable="true" hflex="1">
      			<menuitem label="test long long test" />
      			<menuitem label="test long long test" />
      			<menuitem label="test long long test" />
      			<menuitem label="test long long test" />
      			<menuitem label="test long long test" />
      			<menuitem label="test long long test" />
      			<menuitem label="test long long test" />
      		</menubar>
      	</div>
      </zk>
      

      resize the window to trigger default / scrollable mode

            DevChu DevChu
            MDuchemin MDuchemin
            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 - 1 hour
                1h