Footer language drop-down doesn't match header language drop-down
Categories
(developer.mozilla.org Graveyard :: General, defect, P1)
Tracking
(Not tracked)
People
(Reporter: peterbe, Assigned: espressive)
References
Details
(Keywords: in-triage, Whiteboard: [points=1])
Attachments
(3 files, 2 external files)
Take a random page and open the language drop-down menu. It's English by default. It presents Korean, Japanese, and simplified Chinese.
However, in the footer the menu is very different. Actually, I think it's one entry per every django.conf.settings.AVAILABLE_LOCALES.
If you chose a language, from the footer language menu, you get into a document where the "chrome" is translated but the content isn't. E.g. Swedish
| Reporter | ||
Comment 1•7 years ago
|
||
Footer doesn't match available languages.
Comment 2•7 years ago
|
||
This is different from what's currently in production where the footer matches the header in that it only show available locales
Updated•7 years ago
|
| Assignee | ||
Updated•7 years ago
|
| Assignee | ||
Comment 3•7 years ago
•
|
||
I have diagnosed the problem, but during the process of fixing it, I discovered a new problem. Here is the details:
The React front end for wiki documents uses a Jinja template called react_document.html. It also has a separate view function on the Django side. The view function for the non-React template adds, among other things, the following to the context:
'document': original_doc,
'other_translations': other_translations,
The language switcher in the footer of wiki document differs from the one on the homepage for example.
{% if (document.is_localizable or document.parent) and other_translations %}
The React template, however, uses the same language switcher in the footer on all pages and therefore we always see all languages listed in the drop-down. When I switched to the wiki specific language switcher for the footer I ran into errors because document and other_translations were not in the context.
I added these via the view function in document.py and all seemed to work fine. That was until I navigated to another page. Because client-side navigation only loads new content for the main body of the document, the footer and header are not updated. This means that the language selector in the footer remains in the state it was when the first full page load happened.
The remedy to this is not to change anything in document.py but instead, to turn the footer into a React component so that it is updated when we navigate the main document. I suspect we will still not have to re-render the entire footer but only the language selector when the document changes. I hope/assume React will be clever enough to do that via diffing the virtual DOM.
Kadir, what are your thoughts here, should I proceed with the work to turn the footer into React?
| Assignee | ||
Comment 4•7 years ago
|
||
As mentioned above, to fix this problem correctly we need to convert the footer to a React component. We are going to hold off on doing that until other larger problems have been resolved so, for the time being we will just remove the lang switcher from the footer.
| Reporter | ||
Comment 5•7 years ago
|
||
Perhaps instead of removing the lang-switcher from the Jinja footer (from react_document.html) you could just write a useEffect that uses the DOM to copy the available languages. E.g.
useEffect(() => {
// Update the <select> in the footer
reRenderOptionsInFooter(document.querySelector('#footer select.language'), this.props.documentData.oterh_translations));
});
Certainly feels easy if all you do is suggest it in a comment.
Or, perhaps rewriting it entirely in React isn't hard.
| Assignee | ||
Comment 6•7 years ago
|
||
(In reply to Peter Bengtsson [:peterbe] from comment #5)
Perhaps instead of removing the lang-switcher from the Jinja footer (from react_document.html) you could just write a
useEffectthat uses the DOM to copy the available languages. E.g.useEffect(() => { // Update the <select> in the footer reRenderOptionsInFooter(document.querySelector('#footer select.language'), this.props.documentData.oterh_translations)); });Certainly feels easy if all you do is suggest it in a comment.
That is one option but it feels a little hacky(to me anyway ;p)
Or, perhaps rewriting it entirely in React isn't hard.
My preference would be to
- Convert the footer to a react component already ;)
- For now, just remove the offending lang selector
| Assignee | ||
Comment 7•7 years ago
|
||
After further discussion we have decided to:
- Remove the lang switcher in the footer (we do not intend to bring it back in future)
- Reactify the footer
| Reporter | ||
Comment 8•7 years ago
|
||
The search page is currently the only type of page that is 100% client side. It loads the skeleton which is the header, an empty body/main, and a footer. Then, once the skeleton and the static .js files are downloaded, it starts the XHR and eventually fills up the body so that the footer gets pushed way down.
If you decide to rewrite the footer in React, that'll solve the problem for search. But we could also solve the site-search by making it SSR too.
| Reporter | ||
Comment 9•7 years ago
|
||
Also, for the record, I for one would support deleting the footer language drop-down. It's just more stuff that isn't needed.
- It weighs down the HTML body on every single page.
- It's so weird that it's different from the "fancier"/customized langauge drop-down near the header.
- If you don't need to do much smarts within the footer, it'd basically just be a matter of copying the Jinja (or HTML) code into JSX and indent it a little.
Comment 10•7 years ago
|
||
Comment 11•7 years ago
|
||
Comment 12•6 years ago
|
||
Updated•6 years ago
|
Description
•