-
-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Color field: options query support #6056
Color field: options query support #6056
Conversation
@distantnative Could you please add examples to the XSS lab in the sandbox (basically copying the examples for the other options fields) to ensure that we never accidentally introduce XSS? Options fields are always a bit tricky here. |
Something is weird. I cannot get a single setup in the lab running for some reason. @distantnative Could you post your test blueprint setup here? |
@bastianallgeier that's already included in the first post here. use it together with e.g. this config option 'my' => [
'colors' => [
'#3e3e3e',
'#aaa',
'#ddd',
]
] |
dfd93ac
to
be99f42
Compare
So weird. I must have had a typo somewhere. I tried the blueprint and added my own config options for it, but it didn't work the first time. Now it's all fine. |
@distantnative I have added the various "options" configurations for the color field to our XSS sandbox and discovered some bugs: Actual bug
Consistency issues compared to other options fields
I think it would also be good to add PHPUnit tests for the new options features to the |
I'll try to take a look at the examples to better understand your comments. I think the first one is that if your return direct PHP for an option this has to be already in the correct format (as with other parts in Kirby, e. g. programmable blueprints). So no magic rewriting form associative array. But I'll need to have a closer look on that. The second part I don't quite understand. Where and why should the color field now render HTML? |
Hm, then maybe I misunderstood the release notes snippet from the first post. I've also tried returning
The labels for all options fields except |
I think we still need to look at the context of the field and still dont see why and how HTML would make sense for the color field here, similarly to how it's not for the select field. |
The only reason why the select field does not support HTML is that the |
Another thing I thought about is the flipped text and value props. With an associative array those allow to use the same key/value structure as with the hardcoded options, but with more complex data or customized queries it's IMO really confusing that the color code is the Maybe it was a mistake to make the labels the keys in the hardcoded options. Was there a technical reason why we did it that way and not like |
I also wondered if that was a mistake, but I don't think we could easily change this now, or do you have an idea? Let's continue here: #6101 |
This PR …
Features
options
When passing an options array, keep in mind that keys will be used as the color values and the corresponding array value as preview text (for associative arrays, simple arrays are all color values only).
Ready?
For review team