From e124d8a22700b1ec4b989b8fa52226468c78b5b9 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 2 Feb 2026 17:51:52 -0600 Subject: [PATCH] Enhance TextInput and filtering functionality in ConfirmingPage - Added support for onChanged event in TextInput to handle real-time text updates. - Updated ConfirmingPage to utilize onChanged for filter input, improving user interaction. - Refactored wildcard matching function in PatchVisualizer to support case-insensitive substring matching, enhancing filtering capabilities. --- .../App/Components/PatchVisualizer/init.lua | 24 ++++++++++--------- plugin/src/App/Components/TextInput.lua | 10 +++++++- plugin/src/App/StatusPages/Confirming.lua | 4 ++-- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/plugin/src/App/Components/PatchVisualizer/init.lua b/plugin/src/App/Components/PatchVisualizer/init.lua index 775e2083..c26f9e9c 100644 --- a/plugin/src/App/Components/PatchVisualizer/init.lua +++ b/plugin/src/App/Components/PatchVisualizer/init.lua @@ -15,30 +15,32 @@ local e = Roact.createElement local DomLabel = require(script.DomLabel) --- Convert wildcard pattern (with *) to case-insensitive match --- e.g., "player*sync" matches "PlayerDataSync" -local function matchesWildcard(name: string, pattern: string): boolean - if pattern == "" then +-- Case-insensitive substring match with wildcard support +-- * = one or more characters (.+ in regex) +-- e.g., "player" matches "PlayerDataSync", "MyPlayer", etc. +-- e.g., "player*sync" matches "PlayerDataSync" but not "PlayerSync" +local function matchesFilter(name: string, filter: string): boolean + if filter == "" then return true end -- Escape Lua pattern special chars except * - local escaped = pattern:gsub("([%.%+%-%?%^%$%(%)%[%]%%])", "%%%1") - -- Convert * to .* (match any characters) - local luaPattern = "^" .. escaped:gsub("%*", ".*") .. "$" + local escaped = filter:gsub("([%.%+%-%?%^%$%(%)%[%]%%])", "%%%1") + -- Convert * to .+ (one or more characters) + local pattern = escaped:gsub("%*", ".+") - return string.match(name:lower(), luaPattern:lower()) ~= nil + return string.match(name:lower(), pattern:lower()) ~= nil end -- Check if node or any of its descendants match the filter -local function nodeOrDescendantMatches(node, pattern: string): boolean - if matchesWildcard(node.name or "", pattern) then +local function nodeOrDescendantMatches(node, filter: string): boolean + if matchesFilter(node.name or "", filter) then return true end if node.children then for _, child in node.children do - if type(child) == "table" and nodeOrDescendantMatches(child, pattern) then + if type(child) == "table" and nodeOrDescendantMatches(child, filter) then return true end end diff --git a/plugin/src/App/Components/TextInput.lua b/plugin/src/App/Components/TextInput.lua index 1187296b..fd80a9e0 100644 --- a/plugin/src/App/Components/TextInput.lua +++ b/plugin/src/App/Components/TextInput.lua @@ -108,7 +108,15 @@ function TextInput:render() end, [Roact.Event.FocusLost] = function(rbx) - self.props.onEntered(rbx.Text) + if self.props.onEntered then + self.props.onEntered(rbx.Text) + end + end, + + [Roact.Change.Text] = function(rbx) + if self.props.onChanged then + self.props.onChanged(rbx.Text) + end end, }), Children = Roact.createFragment(self.props[Roact.Children]), diff --git a/plugin/src/App/StatusPages/Confirming.lua b/plugin/src/App/StatusPages/Confirming.lua index 13764fc5..8d88cdf0 100644 --- a/plugin/src/App/StatusPages/Confirming.lua +++ b/plugin/src/App/StatusPages/Confirming.lua @@ -142,12 +142,12 @@ function ConfirmingPage:render() FilterInput = e(TextInput, { text = self.state.filterText, - placeholder = "Filter (* = wildcard)", + placeholder = "Filter", enabled = true, transparency = self.props.transparency, size = UDim2.new(0.5, -5, 1, 0), position = UDim2.new(0.5, 5, 0, 0), - onEntered = function(text) + onChanged = function(text) self:setState({ filterText = text }) end, }),