IDEMPIERE-5520 Navigation between Tabs leave Detached DOM objects (Leak) (#1647)

- Find find window error (duplicate id)
This commit is contained in:
hengsin 2023-01-25 20:17:47 +08:00 committed by GitHub
parent 60678973a4
commit a9ae3b8652
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -33,6 +33,7 @@ import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.stream.Collectors;
import org.adempiere.exceptions.DBException;
import org.adempiere.util.Callback;
@ -1981,7 +1982,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
int record_ID = adTabbox.getSelectedGridTab().getRecord_ID();
if (adTabbox.getSelectedGridTab().getTabLevel() == 0 && record_ID != masterRecord) {
clenFindWindowHashMap();
cleanFindWindowHashMap();
masterRecord = record_ID;
}
@ -4119,8 +4120,15 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
* Clean all the detail cached FindWindow objects
* when the master record is changed
*/
private void clenFindWindowHashMap() {
private void cleanFindWindowHashMap() {
List<FindWindow> list = tabFindWindowHashMap.entrySet().stream().filter(e -> e.getKey().getTabLevel() != 0)
.map(Map.Entry::getValue)
.collect(Collectors.toList());
tabFindWindowHashMap.keySet().removeIf(tab -> tab.getTabLevel() != 0);
if (!list.isEmpty()) {
list.forEach(e -> AEnv.detachInputElement(e));
Executions.schedule(getComponent().getDesktop(), e -> list.forEach(f -> f.detach()), new Event("onDetachCacheFindWindow"));
}
}
private void clearTitleRelatedContext() {

View File

@ -349,7 +349,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
this.setMaximizable(false);
this.setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "findWindow");
this.setId("findWindow_"+targetWindowNo);
this.setId("findWindow_"+targetWindowNo+"_"+targetTabNo);
LayoutUtils.addSclass("find-window", this);
addEventListener(Events.ON_CANCEL, e -> onCancel());