Conversation
…util.js The cellCreator function in OpenmrsSearch.js returned options.data directly when it was already a TD element. The newer DWR util.js (from org.openmrs.contrib) then calls cell.appendChild(data) on the returned cell, but since cell === data, this throws 'Node.appendChild: The new child is an ancestor of the parent' on pages like Find Duplicate Patients and concept search popups. Fix: Create a new TD element in cellCreator and transfer all attributes and child nodes from the original, so the returned cell is always a different object from the data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes LUI-208: On legacyUI >=2.x, pages like Find Duplicate Patients and concept search popups (e.g., in Manage Programs) throw:
Root Cause
The
cellCreatorfunction inOpenmrsSearch.jsreturnedoptions.datadirectly when it was already a<td>element. The newer DWRutil.js(fromorg.openmrs.contrib) then callscell.appendChild(data)on the returned cell. Sincecell === data(same object), this is effectivelynode.appendChild(node), which throws the DOM hierarchy error.The older DWR
util.js(fromorg.openmrs.directwebremoting) had a guard (if (td != reply)) that skipped content-setting when the cell was the same object as the data. The newer version does not have this guard.Fix
Modified
cellCreatorinOpenmrsSearch.jsto create a new<td>element and transfer all attributes (className,id,colSpan, event handlers) and child nodes from the original. The original is then cleared to prevent duplicate IDs. Since the returned cell is now a different object from the data, DWR'sappendChildcall operates on two distinct elements and succeeds.Changes
OpenmrsSearch.jscellCreatorto create new TD instead of returning data directlyDWRPatientServiceTest.javafindDuplicatePatientsandfindPatientsByIdentifierDWRConceptServiceTest.javaDWRPatientService-duplicatePatients.xmlSteps to Verify