Skip to content

LUI-210: Update and enhance jQuery methods for the latest jQuery version#244

Open
sudhanshu-raj wants to merge 1 commit intoopenmrs:masterfrom
sudhanshu-raj:LUI-210
Open

LUI-210: Update and enhance jQuery methods for the latest jQuery version#244
sudhanshu-raj wants to merge 1 commit intoopenmrs:masterfrom
sudhanshu-raj:LUI-210

Conversation

@sudhanshu-raj
Copy link

Replaced deprecated .live() with .on() for jQuery 3.x compatibility, added jQuery Migrate sourced from OpenMRS Core to bridge remaining compatibility gaps, updated openmrs.js to fix the autocomplete dropdown showing raw HTML as text due to a jQuery UI 1.9 and above breaking change, and add a guard in openmrs.js to prevent a TypeError when a null item/object is selected in autocomplete.

Jira Link : https://openmrs.atlassian.net/browse/LUI-210

.appendTo(ul);
};
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More on this change : In jQuery UI 1.9+, the autocomplete widget changed its _renderItem function from using .html() to .text() when setting the label content. .text() escapes everything , so tags become literal visible text instead of HTML elements.

The old jQuery UI used .html(), so the HTML-formatted labels rendered correctly. With the newer jQuery UI bundled in Core 3.x, it switched to .text() for security reasons.

}
jquerySelectEscaped(formFieldId).val(ui.item.object[valueField]);
if (ui.item.object && callBack) {
if (callBack) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

607-610 : It's just extra improvement for existing code, in this way it could not select the null object by any chance which leads to fatal exceptions.

@sudhanshu-raj
Copy link
Author

Hi @dkayiwa , just a quick reminder. Please share your thoughts when you get a chance.

@aadvik93
Copy link

Thanks for the update!

I noticed the changes replace deprecated .live() calls with $(document).on(...), which improves compatibility with newer jQuery versions. The additional null check before accessing autocomplete.options also looks helpful to prevent potential errors.

One question: do we already have any UI or integration tests that cover this autocomplete behavior or would it make sense to add one to ensure it works correctly with the newer jQuery version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants