diff --git a/app/javascript/packs/userProfileSettings.js b/app/javascript/packs/userProfileSettings.js index 7847e0805..a0ba5164b 100644 --- a/app/javascript/packs/userProfileSettings.js +++ b/app/javascript/packs/userProfileSettings.js @@ -4,10 +4,11 @@ const profileFields = document.querySelectorAll('[id^="profile["]'); export function fieldCharacterLimits() { profileFields.forEach((node) => { const field = document.getElementById(node.id); - const fieldValueLength = field.value.length; + const fieldValueLength = [...field.value].length; // 😀 counts as 1 const fieldCharacterSpan = document.getElementById( field.dataset.characterSpanId, ); + // TODO: [yheuhtozr] make the entire fraction into one i18n string fieldCharacterSpan.innerHTML = fieldValueLength; }); @@ -16,8 +17,9 @@ export function fieldCharacterLimits() { return; } - document.getElementById(event.target.dataset.characterSpanId).innerHTML = - event.target.value.length; + document.getElementById(event.target.dataset.characterSpanId).innerHTML = [ + ...event.target.value, + ].length; }); } diff --git a/app/views/users/_profile.html.erb b/app/views/users/_profile.html.erb index 874a0ae24..1bec0a1e0 100644 --- a/app/views/users/_profile.html.erb +++ b/app/views/users/_profile.html.erb @@ -70,7 +70,7 @@ aria: { describedby: "url-description" }, data: { character_span_id: "url-characters" } %>
- Available characters used: + <%= t("views.settings.characters") %> /100
@@ -87,7 +87,7 @@ aria: { describedby: "location-description" }, data: { character_span_id: "location-characters" } %>- Available characters used: + <%= t("views.settings.characters") %> /100
@@ -104,7 +104,7 @@ aria: { describedby: "summary-description" }, data: { character_span_id: "summary-characters" } %>- Available characters used: + <%= t("views.settings.characters") %> /200
@@ -146,7 +146,7 @@ data: { character_span_id: "#{field.attribute_name}-characters" }, class: "crayons-textfield") %>- Available characters used: + <%= t("views.settings.characters") %> /<%= character_count_denominator(field["input_type"]) %>
<% end %> diff --git a/config/locales/views/settings/en.yml b/config/locales/views/settings/en.yml index 97ea73c0b..e78c0eca3 100644 --- a/config/locales/views/settings/en.yml +++ b/config/locales/views/settings/en.yml @@ -64,6 +64,7 @@ en: make: Make primary primary: primary remove: Remove card + characters: "Available characters used: " complete: heading: Confirm your email to complete your profile. desc: While you're at it, go ahead and fill everything out. diff --git a/config/locales/views/settings/fr.yml b/config/locales/views/settings/fr.yml index 0272134a7..09c42a1c8 100644 --- a/config/locales/views/settings/fr.yml +++ b/config/locales/views/settings/fr.yml @@ -64,6 +64,7 @@ fr: make: Make primary primary: primary remove: Remove card + characters: "Available characters used: " complete: heading: Confirm your email to complete your profile. desc: While you're at it, go ahead and fill everything out.