fix character limits i18n (#15830)
This commit is contained in:
parent
7d80475f1a
commit
5253717797
4 changed files with 11 additions and 7 deletions
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
aria: { describedby: "url-description" },
|
||||
data: { character_span_id: "url-characters" } %>
|
||||
<p id="url-description" class="crayons-field__description align-right">
|
||||
<span class="screen-reader-only">Available characters used: </span>
|
||||
<span class="screen-reader-only"><%= t("views.settings.characters") %></span>
|
||||
<span id="url-characters"></span>/100
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -87,7 +87,7 @@
|
|||
aria: { describedby: "location-description" },
|
||||
data: { character_span_id: "location-characters" } %>
|
||||
<p id="location-description" class="crayons-field__description align-right">
|
||||
<span class="screen-reader-only">Available characters used: </span>
|
||||
<span class="screen-reader-only"><%= t("views.settings.characters") %></span>
|
||||
<span id="location-characters"></span>/100
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
aria: { describedby: "summary-description" },
|
||||
data: { character_span_id: "summary-characters" } %>
|
||||
<p id="summary-description" class="crayons-field__description align-right">
|
||||
<span class="screen-reader-only">Available characters used: </span>
|
||||
<span class="screen-reader-only"><%= t("views.settings.characters") %></span>
|
||||
<span id="summary-characters"></span>/200
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -146,7 +146,7 @@
|
|||
data: { character_span_id: "#{field.attribute_name}-characters" },
|
||||
class: "crayons-textfield") %>
|
||||
<p id="<%= field.attribute_name %>-description" class="crayons-field__description align-right">
|
||||
<span class="screen-reader-only">Available characters used: </span>
|
||||
<span class="screen-reader-only"><%= t("views.settings.characters") %></span>
|
||||
<span id="<%= field.attribute_name %>-characters"></span>/<%= character_count_denominator(field["input_type"]) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue