Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert ZK-5026 to fix ZK-5235: Opening a menupopup moves a scrollbar of a long menu back to top #3022

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions zkdoc/release-note
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ZK 10.0.0
ZK-5468: Components with Model only renders one item with wrong result if the EL contains forEachStatus.index
ZK-5490: Grid's [aria-*] attributes do not match their roles
ZK-5525: Checkbox tristate [aria-checked] attribute missing "mixed" state
ZK-5235: Opening a menupopup moves a scrollbar of a long menu back to top


* Upgrade Notes
Expand All @@ -74,6 +75,7 @@ ZK 10.0.0
+ Remove Acronym, Big, Center, Dir, Font, isindex, Nobr, Param, Rtc, and Tt in ZHTML module
+ Remove Applet, Flash, and FusionChart components since ZK 10.0.0
+ Deprecated org.zkoss.zk.ui.uuidRecycle.disabled since ZK 10.0.0
+ Revert ZK-5026 which the original bug cannot be reproduced to fix ZK-5235.

--------
ZK 9.6.4
Expand Down
33 changes: 33 additions & 0 deletions zktest/src/main/webapp/test2/B100-ZK-5235.zul
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
B100-ZK-5235.zul

Purpose:

Description:

History:
Thu Aug 17 17:24:19 CST 2023, Created by rebeccalai

Copyright (C) 2023 Potix Corporation. All Rights Reserved.
-->
<zk>
<label multiline="true">
1. scroll down to hover on the "last" menu and wait for the menupopup to show
2. the scroll bar stays at the current position (if bug exists then goes back to the top)
</label>
<menubar>
<menu id="longMenu" label="long menu">
<menupopup>
<forEach begin="1" end="50">
<menuitem label="${each}"/>
</forEach>
<menu id="childMenu" label="last">
<menupopup>
<menuitem label="inner item"/>
</menupopup>
</menu>
</menupopup>
</menu>
</menubar>
</zk>
1 change: 1 addition & 0 deletions zktest/src/main/webapp/test2/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3157,6 +3157,7 @@ B90-ZK-4431.zul=A,E,Multislider
##zats##B100-ZK-5468-Stepbar.zul=A,E,Model,Stepbar
##zats##B100-ZK-5468-Tabbox.zul=A,E,Model,Tabbox
##zats##B100-ZK-5468-Tree.zul=A,E,Model,Tree
##zats##B100-ZK-5235.zul=A,E,Menu,Menupopup,focus

##
# Features - 3.0.x version
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* B100_ZK_5235Test.java

Purpose:

Description:

History:
Mon Aug 21 13:04:26 CST 2023, Created by rebeccalai

Copyright (C) 2023 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.zktest.zats.test2;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.interactions.Actions;

import org.zkoss.test.webdriver.WebDriverTestCase;

/**
* @author rebeccalai
*/
public class B100_ZK_5235Test extends WebDriverTestCase {
@Test
public void test() {
Actions act = new Actions(connect());

click(jq("$longMenu"));
waitResponse();
assertTrue(jq(".z-menupopup-open").isVisible());

act.moveToElement(toElement(jq("$childMenu"))).perform();
waitResponse();
assertTrue(jq("$childMenu").hasClass("z-menu-hover"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.openqa.selenium.interactions.Actions;

import org.zkoss.test.webdriver.WebDriverTestCase;
import org.zkoss.test.webdriver.ztl.JQuery;

/**
* @author jumperchen
Expand Down Expand Up @@ -55,10 +56,11 @@ public void test() {
.perform();

assertTrue(jq(" .z-menuitem.z-menuitem-hover").exists());
JQuery childMenupopup = jq(".z-menupopup-content").eq(1);
act.sendKeys(Keys.DOWN).perform();
assertTrue(jq(".z-menupopup-content > .z-menuitem:nth-child(2)").hasClass("z-menuitem-hover"));
assertTrue(childMenupopup.children(".z-menuitem:first-child").hasClass("z-menuitem-hover"));

act.sendKeys(Keys.DOWN).perform();
assertTrue(jq(".z-menupopup-content > .z-menuitem:nth-child(3)").hasClass("z-menuitem-hover"));
assertTrue(childMenupopup.children(".z-menuitem:nth-child(2)").hasClass("z-menuitem-hover"));
}
}
4 changes: 0 additions & 4 deletions zul/src/main/resources/web/js/zul/menu/Menupopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,6 @@ export class Menupopup extends zul.wgt.Popup {

/** @internal */
addActive_(wgt: zk.Widget): void {
// ZK-5026
if (zk.currentFocus != this) {
this.getAnchor_()?.focus();
}
this._curIndex = _indexOfVisibleMenu(this, wgt);
}

Expand Down