Closed shawnbot closed 3 years ago
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/sfds/formio-sfds/qntpt53fq
✅ Preview: https://formio-sfds-git-force-lang-redraw.sfds.vercel.app
Size Change: +183 B (0%)
Total Size: 92.1 kB
Filename | Size | Change | |
---|---|---|---|
dist/formio-sfds.standalone.js |
68.3 kB | +183 B (0%) |
Over in #154 I detailed why I think Filipino translations aren't working on some forms. This is a fix, which you can test by repeatedly reloading this preview URL and comparing how it (for me, at least) always displays the Filipino translations. (The sf.gov URL does not.)
The problem appears to be that the form isn't explicitly redrawn after translations are loaded. Now, I'm not 100% sure about why this works, because our patched
Formio.createForm()
implementation fetches the Phrase translations before patching the form model object, which should always force a redraw.My guess is that translations are being loaded, the model is being patched, then the language attribute is being changed by Google Translate, which triggers our
updateLanguage()
function, and this patch just adds anotherredraw()
call that forces the form to apply the new translations. But the failure state is hard to simulate because it's based on a very specific order of operations. The only proof I have that it works is by reloading the preview page over and over again in a real browser. 😬