nova-json icon indicating copy to clipboard operation
nova-json copied to clipboard

Fix removing to much when creating a dotted attribute key

Open gisostallenberg opened this issue 2 years ago • 3 comments
trafficstars

When having a JSON structure with nested data with a key ending (or being the same as the parent property to much is removed from the attribute when it is converted into a dotted key.

Example:

{
  "settings": {
    "personal_settings": {
      "darkmode": true
    }
}

Without this fix a call to getDottedAttributeKey will give the attribute personal_darkmode instead of the expected personal_settings.darkmode.

gisostallenberg avatar Aug 02 '23 14:08 gisostallenberg

@gisostallenberg, can you please post the code which defines the nested JSON field?

Naoray avatar Aug 03 '23 08:08 Naoray

Because the issue occurs in a private project the initial example is made up. The fields are generated from some nested classes, so I'm not 100% sure if the code below is accurate, but I think so.

JSON::make('settings', [
   JSON::make('personal_settings', [
       Boolean::make('darkmode', 'darkmode'),
   ])
])

gisostallenberg avatar Aug 04 '23 08:08 gisostallenberg

Is there some other fields or panel defined which wraps around the JSON definition?

Naoray avatar Aug 04 '23 08:08 Naoray