1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-24 13:43:12 +02:00

Don't allow empty option names

This commit is contained in:
Chen-I Lim 2020-10-24 11:33:20 -07:00
parent f295c783f7
commit 39680fe6d4
2 changed files with 12 additions and 4 deletions

View File

@ -309,6 +309,8 @@ class BoardComponent extends React.Component<Props, State> {
<Editable
className={`octo-label ${group.option.color}`}
text={group.option.value}
placeholderText='New Select'
allowEmpty={false}
onChanged={(text) => {
this.propertyNameChanged(group.option, text)
}}

View File

@ -12,6 +12,7 @@ type Props = {
style?: React.CSSProperties
isMarkdown: boolean
isMultiline: boolean
allowEmpty: boolean
onFocus?: () => void
onBlur?: () => void
@ -26,6 +27,7 @@ class Editable extends React.Component<Props, State> {
text: '',
isMarkdown: false,
isMultiline: false,
allowEmpty: true,
}
private _text = ''
@ -103,11 +105,15 @@ class Editable extends React.Component<Props, State> {
onBlur={async () => {
const newText = this.elementRef.current.innerText
const oldText = this.props.text || ''
if (newText !== oldText && onChanged) {
onChanged(newText)
}
if (this.props.allowEmpty || newText) {
if (newText !== oldText && onChanged) {
onChanged(newText)
}
this.text = newText
this.text = newText
} else {
this.text = oldText // Reset text
}
this.elementRef.current.classList.remove('active')
if (onBlur) {