Automattic / Automattic/custom-metadata
Clonable fields reordering on save
- Dominant language
- PHP
- Stars
- 190
- Forks
- 46
- Avg merge
- 46m
- Merged PRs (30d)
- 15
Description
The 0.5 release states:
```
NOTE: currently multiplied fields will display out of order after saving, however this should not affect anything else other than the admin, should be fixed soon
```
However, each save action actually actually saves these items in the wrong order. When they are echoed out on the front end they continually flip orders with each concurrent save of the page. It seems that reversing the array before writing it to the admin screen fixes this issue to always save it in the same order. In custom_metadata.php, on line 1193 I added the following as a temporary quick fix:
```
// reverse array
if ( count($value) > 1 ) :
$value = array_reverse( $value );
endif;
```
Contributor guide
Research direction
Inspect custom_metadata.php around line 1193 and reproduce saves involving multiple clonable fields. Verify that repeated or concurrent saves preserve the same item order in the admin and front-end output, with no order flipping between saves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100