Set array to blank string when array is empty (FE) #22884
Closed
+4
−0
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:
This change ensures that jQuery's serialization sends a value to the backend even when an array is empty. By default, jQuery would omit empty arrays during serialization, which could cause issues on the backend.
Initially, I considered handling this on the backend by populating any setting with a name but no value as an empty array. However, this approach carried potential side effects for API consumers, so it was deemed too risky.
Instead, this solution is simple and low-risk. It ensures that a value is always sent to the backend, allowing settings to be processed and saved correctly without impacting existing API behavior.
Downside
This then stores the setting as an empty string array so
[""]
while this might look odd, it is compatible and does work.Review