From 4dbeb010fe46f1fcf3170486bdf836ae46c29884 Mon Sep 17 00:00:00 2001 From: Aylong <69762909+AyIong@users.noreply.github.com> Date: Sat, 15 Mar 2025 20:37:43 +0200 Subject: [PATCH] [516] Fix TGUI input text max_length (#90039) ## About The Pull Request Fixes default max_lenght on TGUI input text. Chromium ignores symbols in maxlength attribute, so instead of infinity it was... 1. Without setting attribute, it was literally infinite (close enough) ![image](https://github.com/user-attachments/assets/7a6c643c-c43c-4bad-bd26-b8b22145a3d9) Closes #89331 ## Why It's Good For The Game ![image](https://github.com/user-attachments/assets/8421f8af-5bf7-45bf-bd2e-1d54e3f98c6d) ## Changelog :cl: fix: Fixed TGUI text inputs, that's allows only 1 symbol instead infinity /:cl: --- code/modules/tgui_input/text.dm | 6 +++--- tgui/packages/tgui/interfaces/TextInputModal.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/code/modules/tgui_input/text.dm b/code/modules/tgui_input/text.dm index 2476ec16342..95eaa02f7ed 100644 --- a/code/modules/tgui_input/text.dm +++ b/code/modules/tgui_input/text.dm @@ -10,12 +10,12 @@ * * message - The content of the text input, shown in the body of the TGUI window. * * title - The title of the text input modal, shown on the top of the TGUI window. * * default - The default (or current) value, shown as a placeholder. - * * max_length - Specifies a max length for input. MAX_MESSAGE_LEN is default (1024) + * * max_length - Specifies a max length for input. By default is infinity. * * multiline - Bool that determines if the input box is much larger. Good for large messages, laws, etc. * * encode - Toggling this determines if input is filtered via html_encode. Setting this to FALSE gives raw input. * * timeout - The timeout of the textbox, after which the modal will close and qdel itself. Set to zero for no timeout. */ -/proc/tgui_input_text(mob/user, message = "", title = "Text Input", default, max_length = INFINITY, multiline = FALSE, encode = TRUE, timeout = 0, ui_state = GLOB.always_state) +/proc/tgui_input_text(mob/user, message = "", title = "Text Input", default, max_length, multiline = FALSE, encode = TRUE, timeout = 0, ui_state = GLOB.always_state) if (!user) user = usr if (!istype(user)) @@ -162,4 +162,4 @@ /datum/tgui_input_text/proc/set_entry(entry) if(!isnull(entry)) var/converted_entry = encode ? html_encode(entry) : entry - src.entry = trim(converted_entry, PREVENT_CHARACTER_TRIM_LOSS(max_length)) + src.entry = max_length ? trim(converted_entry, PREVENT_CHARACTER_TRIM_LOSS(max_length)) : converted_entry diff --git a/tgui/packages/tgui/interfaces/TextInputModal.tsx b/tgui/packages/tgui/interfaces/TextInputModal.tsx index 04b6005bdc0..38c709a3aa7 100644 --- a/tgui/packages/tgui/interfaces/TextInputModal.tsx +++ b/tgui/packages/tgui/interfaces/TextInputModal.tsx @@ -83,7 +83,7 @@ export const TextInputModal = (props) => {