From 162063025cccf3006c33a096da845e808556da83 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sat, 25 Apr 2020 09:38:04 +0200 Subject: [PATCH] Add missing form.js for field value update (:focus style) --- assets/js/app.js | 1 + assets/js/forms.js | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 assets/js/forms.js diff --git a/assets/js/app.js b/assets/js/app.js index fc7c539..ce75569 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,5 +1,6 @@ import './external_links'; import './message_icons'; +import './forms'; import '../sass/app.scss'; diff --git a/assets/js/forms.js b/assets/js/forms.js new file mode 100644 index 0000000..4161467 --- /dev/null +++ b/assets/js/forms.js @@ -0,0 +1,11 @@ +// For labels to update their state (css selectors based on the value attribute) +document.addEventListener('DOMContentLoaded', () => { + document.querySelectorAll('input').forEach(el => { + if (el.type !== 'checkbox') { + el.setAttribute('value', el.value); + el.addEventListener('change', () => { + el.setAttribute('value', el.value); + }); + } + }); +}); \ No newline at end of file