ec-jrc / re3gistry

Re3gistry is a reusable open source solution for managing and sharing ‘reference codes’, ensuring semantic interoperability across organisations.
European Union Public License 1.2
27 stars 21 forks source link

Fix timing issue, run init after DOM has the elements #345

Closed ZakarFin closed 3 months ago

ZakarFin commented 6 months ago

Apparently this component package is used to run some JavaScript for creating the language selection etc. This https://github.com/ec-jrc/re3gistry/blob/v2.5.1/sources/Re3gistry2/src/main/webapp/jsp/includes/header.inc.jsp#L32C61-L32C92 basically means that the ECL.autoinit() will try to run this code https://github.com/ec-europa/europa-component-library/blob/v3.12.1/src/implementations/vanilla/components/site-header/site-header.js#L127 and find elements on the page.

The JavaScript can't find the elements if it is run before the elements are in the DOM so moving the ECL.autoInit() call to the end of the page makes the language select at least open. Looks like it still doesn't change the languages, but it might be a configuration problem on my instance. It also lists more languages that I selected to be used on my Re3gistry instance which is a bit annoying.

Language selection on the header: image

When clicked after the change: image

I noticed there's a HTML <select> element for language selection as well on the DOM and some code on a common.js file refers to it by ID, but I can't see where it's actually shown.

ZakarFin commented 3 months ago

Solved in #373. Though now the ECL.autoInit() is called twice:

Not sure if this is a problem, but I guess not.