Skip to content

Fix broken translated field after form errors#3026

Merged
oriolgual merged 19 commits intomasterfrom
fix/broken_translated_field_after_form_errors
Mar 19, 2018
Merged

Fix broken translated field after form errors#3026
oriolgual merged 19 commits intomasterfrom
fix/broken_translated_field_after_form_errors

Conversation

@deivid-rodriguez
Copy link
Copy Markdown
Contributor

🎩 What? Why?

When working on some features for surveys, I noticed a small bug:

  • 🐛 When a freshly created question has errors, the question will be re-rendered but the translated field tabs for the statement won't work.

I started fixing it, but the jquery-tmpl library was giving me some trouble:

  • 💣 The interpolation variable (${tabsId}) that it uses was being included in the href of the translated field tabs, and that was making foundation-tabs crash and preventing the tabs from being enabled.

I couldn't really figure out an easy way to fix that other that not using those interpolation placeholders at all. jquery-tmpl was not really doing much and it seems like an abandoned library that hasn't been updated for 4 years. So I removed its usage and replaced it with some similar custom code.

I'm not sure about the last commit, initially I was globally replacing the "placeholder string" with a unique value, but I was paranoid about someone creating a question like this:

Which string would you like to use as a placeholder?
* survey-question-id
* survey-question-placeholder-id

and unintentionally replacing actual content that I don't want to replace...

📌 Related Issues

None.

📋 Subtasks

  • Add CHANGELOG entry

📷 Screenshots (optional)

Before

before

After

after

So the template can assume its locals are consistently the same type.
Reuse the logic to construct the base id for the attributes' id
construction.
So "calculation" is straightforward and we don't need helper methods.
It'll have already been replaced with a proper value by then.
The placeholder variable "${tabsId}" that is interpolated by this
library is causing errors when you submit a form with a freshly created
translated field and it has errors. The field will be rerendered with
the "${tabsId}" placeholder in the field tabs link destinations and that
will make foundation-tabs crash. That will make it impossible to further
switch tabs in that field.

This library has not been updated for 4 years anyways and new
alternatives are now recommended.
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 18, 2018

Codecov Report

Merging #3026 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #3026      +/-   ##
==========================================
+ Coverage   98.67%   98.67%   +<.01%     
==========================================
  Files        1699     1699              
  Lines       40568    40582      +14     
==========================================
+ Hits        40032    40046      +14     
  Misses        536      536

Copy link
Copy Markdown
Contributor

@mrcasals mrcasals left a comment

Choose a reason for hiding this comment

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

Code looks good to me, I don't see anything that raises suspicions, so it's a go for me!

@oriolgual oriolgual merged commit 276ec83 into master Mar 19, 2018
@ghost ghost removed the status: WIP label Mar 19, 2018
@oriolgual oriolgual deleted the fix/broken_translated_field_after_form_errors branch March 19, 2018 14:15
rbngzlv added a commit that referenced this pull request Mar 21, 2018
* master:
  [RFC] Use cells for meeting m cards (#3022)
  Do not force Postgresql user to be admin when enabling trigram extension (#3053)
  Make organization reference_prefix required (#3056)
  admin can duplicate/copy meetings (#3051)
  Fix question form errors not being displayed (#3046)
  Erb whitespace cutting (#3047)
  Show debates statistics on space show and homepage (#3016)
  Fix broken translated field after form errors (#3026)
  Move decidim executable to "exe" folder (#3028)
  Friendlier buttons (#3027)
  Feedback needed after Endorsing when user has no user_groups (#2998)
  Fix seeding error on generator specs (#3021)
  fix spelling error in threshold (#3019)
  Migration plus seeds (#2933)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants