Skip to content

Conversation

@lubber-de
Copy link
Member

@lubber-de lubber-de commented May 2, 2025

Description

If a JSON value was used as a dropdown item value, it was internally broken as the value was casted to String resulting into [object Object]
Now, having multiple JSON values for more than 1 dropdown item the value couldn't be compared / set correctly as each values had the same [object Object].
This PR fixes it by replacing the simple castings to JSON stringify which keeps the value structure so the dropdown items keep their unique value

Testcase

  • Open console
  • Select "Option A"
  • check the debug log for "Updating input value"

Broken

https://jsfiddle.net/ReiVanBjair/ry4123z0/11/

Fixed

https://jsfiddle.net/lubber/L0ysfoqj/

Screenshots

Broken

image

Fixed

image

Closes

#3005

@lubber-de lubber-de added type/bug Any issue which is a bug or PR which fixes a bug lang/javascript Anything involving JavaScript state/awaiting-reviews Pull requests which are waiting for reviews labels May 2, 2025
@lubber-de lubber-de added this to the 2.10.0 milestone May 2, 2025
Copy link
Member

@ko2in ko2in left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work well with encoded JSON string. https://jsfiddle.net/ko2in/ftpLscv6/

For security, the JSON object usually inserts as encoded format especially from server side like PHP htmlentities function.

Copy link
Member

@ko2in ko2in left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@mvorisek
Copy link
Contributor

mvorisek commented May 19, 2025

Kind of atk4/ui#2274 and related to #3223.

The issue with this PR is "string formatted like valid JSON" will not be formatted as before - ex. input [0 ].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang/javascript Anything involving JavaScript state/awaiting-reviews Pull requests which are waiting for reviews type/bug Any issue which is a bug or PR which fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants