getgrav / getgrav/grav-plugin-admin
Selectize field drops custom values after saving/refreshing input
- Dominant language
- PHP
- Stars
- 377
- Forks
- 225
- Avg merge
- 11h 51m
- Merged PRs (30d)
- 4
Description
Using the `selectize` field, when entering custom values these get dropped in refreshed input field. The number of dropped custom values depend on their position and the number of selected predefined options.
The page itself always contains the right value in the header.
To reproduce:
- Fresh installation Grav v1.6.26 Core + Admin (same happens with Grav v1.7.0.rc14 Core + Admin)
- In theme Quark, add the following to '/user/themes/quark/blueprints/default.yaml' as sibling to field `header.body_classes`:
```
header.selectize:
type: selectize
label: Selectize
selectize:
options:
- text: "optionA"
value: "optionA"
- text: "optionB"
value: "optionB"
- text: "optionC"
value: "optionC"
validate:
type: commalist
```
- Browse to '.../admin/pages/typography'. Form will look like:

- When selecting predefined options and adding custom values, the following happens:
|**Input field** | | **Input field after saveing**|
| -------------- | -- | ------------------------ |
| 1,2,3,4,5,6 | -> | 4,5,6 |
| optionA, 1,2,3,4,5,6 | -> | optionA, 3,4,5,6 |
| optionA, optionB, 1,2,3,4,5,6 | -> | optionA, optionB, 2,3,4,5,6 |
| optionA, optionB, optionC, 1,2,3,4,5,6 | -> | optionA, optionB, optionC, 1,2,3,4,5,6 |
**Note**: Dropped custom values = `count(options) - count(options selected)`
|**Input field** | | **Input field after saving**|
| -------------- | -- | ------------------------ |
|1,2,3,4,5,6,optionA, 7,8,9,0 | -> | 4,5,6,optionA,7,8,9,0 |
|1,2,3,4,5,6,optionA, optionB, 7,8,9,0 | -> | 4,5,6,optionA, optionB,7,8,9,0 |
|1,2,3,4,5,6,optionA, optionB, optionC, 7,8,9,0 | -> | 4,5,6,optionA, optionB, optionC,7,8,9,0 |
**Note**: Dropped custom values = `count(options)`
**Notes**:
- The values in the header of the Markdown page are always correct.
- The values shown in 'Page Source' view are always correct.
Eg. for input `1,2,3,4,5,6,optionA, optionB, 7,8,9,0`, the HTML is:
```
```
- The issue seems to be caused by script `/user/plugins/admin/themes/grav/js/admin.min.js` when it creates the divs to emulate the `selectize` field.
Contributor guide
Assessment
This issue has not been assessed yet.