Skip to content

Commit

Permalink
Remove 'required' prop from Typeahead components
Browse files Browse the repository at this point in the history
  • Loading branch information
jgreben committed Nov 7, 2019
1 parent 7f139e1 commit cbab6ae
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 22 deletions.
1 change: 0 additions & 1 deletion __tests__/components/editor/property/InputListLOC.test.js
Expand Up @@ -131,7 +131,6 @@ describe('InputListLOC', () => {
expect(getByPlaceholderText('Sound characteristics')).toBeInTheDocument()
// Not required.
expect(queryByText('Required')).not.toBeInTheDocument()
expect(getByPlaceholderText('Sound characteristics')).not.toHaveAttribute('required')
// No existing values are present. This sort of a query isn't recommended but since testing for absence, seems OK.
expect(container.querySelector('.rbt-token')).not.toBeInTheDocument()
})
Expand Down
13 changes: 0 additions & 13 deletions __tests__/components/editor/property/InputLookupSinopia.test.js
Expand Up @@ -35,19 +35,6 @@ describe('<InputLookupSinopia />', () => {
expect(wrapper.find('#sinopia-lookup').props().placeholder).toMatch('Name Lookup')
})

it('sets the typeahead component required attribute according to the mandatory property from the template', () => {
expect(wrapper.find('#sinopia-lookup').props().required).toBeFalsy()
})

describe('when mandatory is true', () => {
const template = { ...plProps.propertyTemplate, mandatory: 'true' }
const wrapper2 = shallow(<InputLookupSinopia.WrappedComponent {...plProps} propertyTemplate={template} />)

it('is required', () => {
expect(wrapper2.find('#sinopia-lookup').props().required).toBeTruthy()
})
})

it('sets the typeahead component multiple attribute according to the repeatable property from the template', () => {
expect(wrapper.find('#sinopia-lookup').props().multiple).toBeFalsy()
})
Expand Down
1 change: 0 additions & 1 deletion src/components/ResourceTemplateChoiceModal.jsx
Expand Up @@ -67,7 +67,6 @@ const ResourceTemplateChoiceModal = (props) => {
<AsyncTypeahead onSearch={search}
onChange={change}
options={options}
required={false}
multiple={false}
isLoading={isLoading}
selected={selected}
Expand Down
3 changes: 0 additions & 3 deletions src/components/editor/property/InputListLOC.jsx
Expand Up @@ -29,11 +29,9 @@ const InputListLOC = (props) => {
})

const [isRepeatable, setIsRepeatable] = useState(true)
const [isMandatory, setIsMandatory] = useState(false)
const [lookupConfigs, setlookupConfigs] = useState([])
useEffect(() => {
setIsRepeatable(booleanPropertyFromTemplate(propertyTemplate, 'repeatable', true))
setIsMandatory(booleanPropertyFromTemplate(propertyTemplate, 'mandatory', false))
setlookupConfigs(getLookupConfigItems(propertyTemplate))
}, [propertyTemplate])

Expand Down Expand Up @@ -115,7 +113,6 @@ const InputListLOC = (props) => {
allowNew={() => true }
onChange={selected => selectionChanged(selected)}
id="loc-vocab-list"
required={isMandatory}
multiple={isRepeatable}
placeholder={propertyTemplate.propertyLabel}
emptyLabel="retrieving list of terms..."
Expand Down
2 changes: 0 additions & 2 deletions src/components/editor/property/InputLookupQA.jsx
Expand Up @@ -102,7 +102,6 @@ const InputLookupQA = (props) => {
}
}

const isMandatory = booleanPropertyFromTemplate(props.propertyTemplate, 'mandatory', true)
const isRepeatable = booleanPropertyFromTemplate(props.propertyTemplate, 'repeatable', true)

const setDisabled = () => {
Expand Down Expand Up @@ -136,7 +135,6 @@ const InputLookupQA = (props) => {
<div className={groupClasses}>
<AsyncTypeahead renderMenu={(results, menuProps) => renderMenuFunc(results, menuProps, props.propertyTemplate)}
ref={myInput}
required={isMandatory}
disabled={setDisabled()}
onChange={(selected) => {
const payload = {
Expand Down
2 changes: 0 additions & 2 deletions src/components/editor/property/InputLookupSinopia.jsx
Expand Up @@ -28,7 +28,6 @@ const InputLookupSinopia = (props) => {
return null
}

const isMandatory = booleanPropertyFromTemplate(props.propertyTemplate, 'mandatory', false)
const isRepeatable = booleanPropertyFromTemplate(props.propertyTemplate, 'repeatable', true)

const search = (query) => {
Expand Down Expand Up @@ -77,7 +76,6 @@ const InputLookupSinopia = (props) => {
onChange={change}
onKeyDown={onKeyDown}
options={options}
required={isMandatory}
multiple={isRepeatable}
isLoading={isLoading}
selected={props.selected}
Expand Down

0 comments on commit cbab6ae

Please sign in to comment.