Skip to content

Commit d979bfc

Browse files
committed
Use JS to limit shortname length, but support emoji
1 parent c9f920f commit d979bfc

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script>
2+
const input = document.getElementById('pwa_short_name');
3+
const maxLength = 12;
4+
5+
input.addEventListener('input', () => {
6+
// Use Array.from to count characters correctly
7+
const inputChars = Array.from(input.value);
8+
9+
// If input exceeds maxLength, truncate it
10+
if (inputChars.length > maxLength) {
11+
input.value = inputChars.slice(0, maxLength).join('');
12+
}
13+
});
14+
</script>

event/listener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function pwa_short_sitename($value, $key)
213213
{
214214
$placeholder = $this->trim_shortname($this->config['sitename']);
215215

216-
return '<input id="' . $key . '" type="text" size="40" maxlength="12" name="config[' . $key . ']" value="' . $value . '" placeholder="' . $placeholder . '">';
216+
return '<input id="' . $key . '" type="text" size="40" maxlength="24" name="config[' . $key . ']" value="' . $value . '" placeholder="' . $placeholder . '">';
217217
}
218218

219219
/**

0 commit comments

Comments
 (0)