fix(es_extended/client/functions): remove every matching element in menu.removeElement - #1848
Open
seltonmt012 wants to merge 1 commit into
Open
Conversation
…ement The loop walked the element list forwards while removing from it, so every removal shifted the next entry into the slot the counter had already passed. With consecutive matches only every second one was removed.
N0tNvll
self-requested a review
August 15, 2026 00:34
N0tNvll
approved these changes
Aug 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
menu.removeElementwalks the element list forwards while callingtable.removeon it. Every removal shifts the rest of the list down by one, but the loop counter still goes up, so the element that moved into the freed slot is never looked at. With several matches in a row only every second one gets removed.Motivation
The more elements match, the more survive. Removing by
typefrom a list where every entry matches:bleftb d fleftb dleftda c dlefta dA single match, or matches that are already spread apart, work fine, which is why this goes unnoticed. It breaks as soon as two matching entries sit next to each other, and the caller gets no indication that anything was left behind.
Nothing in the core calls
removeElement. It is part of the menu object returned byESX.UI.Menu.Open, so this only hits resources that build menus and prune them.Implementation Details
Iterate backwards. Indices below the current one are not affected by
table.remove, so nothing gets skipped:I pulled the function straight out of the shipped file and ran it against 12 cases: five with consecutive matches, seven that already worked (single match at the front, middle and end, no match at all, empty list, query on
value, alternating matches). Unpatched it is 7/12, patched 12/12, and the seven that passed before give the same result.Usage Example
PR Checklist