- Issue created by @utkarsh_33
- 🇮🇳India gauravvvv Delhi, India
This issue also occurs when selecting 'None' for the column width. Could you specify which component you encountered this issue with? Thanks!
It occurs for every select element as far as i know.Is there an instance where it works correctly @gauravvvv ?
- 🇳🇱Netherlands balintbrews Amsterdam, NL
I wonder if those "-None-" options should even be there in the first place. Just by looking at a few components, it looks like those values should be required with a default value.
- 🇳🇱Netherlands balintbrews Amsterdam, NL
Maybe this is the same as 🐛 Emptying a required value through the UI crashes the app Active ?
- Assigned to wim leers
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
#5++
Yes, exactly.
When using
type: string, enum: [foo, bar]
, the value MUST be eitherfoo
orbar
— IOW: it is required to pick a value.But the difference is that per #3469855-3: Emptying a required value through the UI crashes the app → , @balintbrews is convinced it can be solved entirely on the client-side. That's true generally speaking, but not for this particular case. This particular case does need it, to avoid the
- None -
option being added (see\Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsSelectWidget::getEmptyLabel()
). - 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Adding missing issue relationships.
Making issue title more specific.
- Merge request !2453471511: `enum` data shapes: error when choosing "- None -" in `<select>` → (Closed) created by wim leers
- Assigned to utkarsh_33
- Status changed to Needs review
4 months ago 8:52am 3 September 2024 - 🇫🇮Finland lauriii Finland
When using type: string, enum: [foo, bar], the value MUST be either foo or bar — IOW: it is required to pick a value.
But if that prop is not required, you should be able to leave it unset. Isn't that what the "- none -" would be for?
- Assigned to lauriii
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
#10: Hm … I wonder then if the problem is that we do not support
default
.IOW:
- a prop with a shape like
enum: […]
that IS NOT listed in the SDC'srequired
MUST have adefault
specified - a prop with a shape like
enum: […]
that IS listed in the SDC'srequired
MAY have adefault
specified
- a prop with a shape like
- Assigned to wim leers
- Status changed to Needs work
4 months ago 9:30am 3 September 2024 - Issue was unassigned.
- 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Verifying fundamentals
For the
experience_builder:heading
SDC, the generatedComponent
config entity does contain:style: field_type: list_string field_storage_settings: allowed_values: - value: primary label: primary - value: secondary label: secondary field_instance_settings: { } field_widget: options_select default_value: value: primary
IOW:
primary
is selected as the default automatically, because that's the first example. So why is this not being respected? 🤔Turns out it is:
So the
default
aspect mentioned in #12 is an irrelevant distraction.So: server allows selecting "nothing", but how to make client know this?
All that matters is what @lauriiii was getting at in #10: if an SDC marks a prop as optional, we should be able to detect that (the "no value entered" scenario). So how do we do that?
Turns out that
form_select_options()
hardcodes a particular special value:_none
— specifically for<select>
. (Even the "list" field type's widget base class must hardcode this knowledge, see\Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsWidgetBase::validateElement()
). It can optionally be overridden using#empty_value
.Conclusion
Select.tsx
, introduced in 🐛 Prop select lists don't affect the component Fixed , needs to be updated to be aware of this special value. If this special value is selected, then:- the UI should interpret this as "no input specified by user"
- the UI should then delete this prop from the model, rather than setting
"_none"
as the value — because that's the whole point of ✨ Contextual form values need to be integrated with Redux Active : to allow real-time updates of the preview based on information on the client side only - that will then prevent this invalid model to be sent from the client to the server:
- Status changed to Closed: duplicate
4 months ago 4:43pm 6 September 2024 - 🇺🇸United States bnjmnm Ann Arbor, MI
I have this solved and will soon have tests for it in my in-progress MR for 🌱 [META] Redux sync on ALL prop types, not just ones with a single [value] property Active . If this is crazy urgent and can't wait on the larger issue feel free to reopen and assign this to me and I'll extract what I have in there.