Skip to content

Commit

Permalink
feat(components): add possibility to change description position and …
Browse files Browse the repository at this point in the history
…keep "addOption" button always

feature/select-with-image
  • Loading branch information
samwx committed Nov 19, 2019
1 parent 7859909 commit dd23b06
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/components/blipSelect/CreatableOptionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class CreatebleOptionsList extends Component {
newOption: '',
addOptionText: '',
emptyMessage: '',
alwaysEnabled: false,
blockNewEntries: false,
OptionCreator: undefined,
}
Expand All @@ -34,6 +35,7 @@ export class CreatebleOptionsList extends Component {
return new OptionCreator({
onOptionClick: this.options.onOptionClick,
onTryAccessInput: this.options.onTryAccessInput,
descriptionPosition: this.props.descriptionPosition,
}).render(optionProps)
}

Expand All @@ -57,10 +59,13 @@ export class CreatebleOptionsList extends Component {
* Check if current state allows to add new option
*/
_canAddOption(newOption) {
return newOption &&
newOption.trim() !== '' &&
!this.props.blockNewEntries &&
!this.props.options.some(o => o.label === newOption)
return (
this.options.alwaysEnabled ||
(newOption &&
newOption.trim() !== '' &&
!this.props.blockNewEntries &&
!this.props.options.some(o => o.label === newOption))
)
}

/**
Expand All @@ -76,7 +81,7 @@ export class CreatebleOptionsList extends Component {
*/
_renderAddOption(newOption) {
const addOptionHtml = this.options.addOptionText
? html`<small class="blip-prompt-add-option">${this.options.addOptionText}:</small>`
? html`<small class="blip-prompt-add-option">${this.options.addOptionText}</small>`
: ''

return this._canAddOption(newOption)
Expand Down

0 comments on commit dd23b06

Please sign in to comment.