Skip to content

Commit 26d0399

Browse files
fix minor issues in tagselect
1 parent b9e3001 commit 26d0399

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/components/TagSelect/TagSelect.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import ReactSelect from '../Select/Select'
33
import FormsySelect from '../Select/FormsySelect'
44
import PropTypes from 'prop-types'
5+
import _ from 'lodash'
56

67
/**
78
* TagSelect renders the tag selection component for attachment options dialog
@@ -27,31 +28,40 @@ export const TagSelect = ({ selectedTags, onUpdate, useFormsySelect, name }) =>
2728
}
2829
}
2930

31+
const onInputChage = (value) => {
32+
// prevent preceding spaces
33+
return _.trimStart(value)
34+
}
35+
3036
return (
3137
<div className="has-react-select">
3238
{
3339
useFormsySelect ?
3440
<FormsySelect
3541
isMulti
42+
heightAuto
3643
name={name}
3744
setValueOnly
3845
closeMenuOnSelect
3946
createOption
4047
showDropdownIndicator={false}
4148
placeholder="Add tags"
49+
onInputChange={onInputChage}
4250
noOptionsMessage={noOptionsMessage}
4351
isValidNewOption={isValidNewOption}
4452
getNewOptionData={getNewOptionData}
4553
/> :
4654
<ReactSelect
4755
isMulti
56+
heightAuto
4857
name={name}
4958
closeMenuOnSelect
5059
createOption
5160
showDropdownIndicator={false}
5261
placeholder="Add tags"
5362
value={(selectedTags || []).map(t => ({ value: t, label: t }))}
5463
onChange={tags => onUpdate(tags.map(t => t.value))}
64+
onInputChange={onInputChage}
5565
noOptionsMessage={noOptionsMessage}
5666
isValidNewOption={isValidNewOption}
5767
getNewOptionData={getNewOptionData}

0 commit comments

Comments
 (0)