Skip to content
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

Content Profile - > Width field although required can be saved without initialization #4371

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function getSelectSingleValue(
<label className="sd-line-input__label">{this.props.formField.label}</label>
<select
disabled={this.props.disabled || this.state.items == null || this.state.items.length < 1}
value={this.props.value || ''}
value={this.props.value || this.state.items[0].id}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like a good solution to me. If the problem is that an empty value is being saved, we can solve it by either adding validation or not allowing empty value. If we're going with an approach of not allowing empty values, we'd need to add a prop to this component and in that case don't render the <option> tag with empty string a a value. The display of value shouldn't be messed with. The value should be displayed as it is.

className="sd-line-input__select"
onChange={(event) => {
this.props.onChange(event.target.value);
Expand Down
Loading