Steps to Reproduce
Run fiddle
https://zkfiddle.org/sample/1bh8for/2-radiogroup-detach-removes-selectedIndex
click button
Current Result
Selected index in radiogroup is set to -1 while detached (because Radio#onPageDetached fires, causes selected index to set to -1 in radiogroup during Radiogroup#fixOnRemove)
Selected index remain -1 after component is reattached (because Radio#onPageAttached fires, but doesn't trigger Radiogroup#fixOnAdd)
Expected Result
When reattached to the same radiogroup, the selected radio should trigger radiogroup#fixOnAdd
Debug Information
Radiogroup#onPageAttached has following condition to trigger fixOnAdd:
if (rg != null && rootParent instanceof ComponentCtrl if (rg != null && rootParent instanceof ComponentCtrl && (!Components.isAncestor(rootParent, rg) || rootParent == rg)) {
https://github.com/zkoss/zk/blob/master/zul/src/org/zkoss/zul/Radio.java#L299-L300
will only fire is the radiogroup is not a descendant of the rootParent, or if rootParent is the radiogroup.
If the radiogroup is a descendant of rootParent (as per fiddle), fixOnAdd doesn't trigger.
Workaround
attached java class RadioExt.java.
deploy globally with lang-addon:
<component> <component-name>radio</component-name> <extends>radio</extends> <component-class>org.zkoss.zul.RadioExt</component-class> </component>
- relates to
-
ZK-4763 Radiogroup selectedIndex error after radio moved
- Closed
-
KEIKAI-585 paste special does not work as expected
- Closed