I'm trying to make the submit button of a TextField to read "done" when there is no text, which would result in nothing happening, but also read "search" when there is text, which would perform a search. I tried to use a ternary operator in the .submitLabel modifier to do this, but it does not change dynamically, only when the user closes out and reopens the TextField.
TextField("Search for meals...", text: $searchText)
.submitLabel(searchText != "" ? .search : .done)