Skip to content

Commit

Permalink
Merge pull request #759 from unitaryfund/debug_autocomplete
Browse files Browse the repository at this point in the history
Fix autocomplete validation
  • Loading branch information
WrathfulSpatula authored Jan 10, 2023
2 parents de8f725 + 02023cc commit ffe2666
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/components/SubmissionRefsAddModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,19 @@ const SubmissionRefsAddModal = (props) => {
if (!i) {
i = item
}
setIsValid(!!i.name && (i.parent || (props.modalMode !== 'Task')))
setIsValid((!!i.id && !showAccordion) || (showAccordion && !!i.name && (i.parent || (key !== 'task'))))
}

const handleAccordionToggle = () => {
setIsValid(showAccordion || (!!item.name && (item.parent || (props.modalMode !== 'Task'))))
setIsValid((!!item.id && showAccordion) || (!showAccordion && !!item.name && (item.parent || (key !== 'task'))))
setShowAccordion(!showAccordion)
}

const handleOnSelectParent = (nItem) => {
if (showAccordion || !nItem) {
if (!showAccordion || !nItem) {
return
}

console.log(nItem)
item.parent = nItem.id
setItem(item)
handleValidation(item)
Expand All @@ -89,7 +88,7 @@ const SubmissionRefsAddModal = (props) => {
}

const handleOnSelectRef = (nItem) => {
if (showAccordion || !nItem) {
if (!nItem) {
setIsValid(false)
return
}
Expand All @@ -100,23 +99,17 @@ const SubmissionRefsAddModal = (props) => {
}

const handleOnChangeRef = (key, value) => {
if (showAccordion) {
return
}

const fn = props.filteredNames.find(f => f.name === value)
if (fn) {
item.id = fn.id
setItem(item)
} else {
item.id = 0
}
setItem(item)
handleValidation(item)
}

const handleOnChangeName = (field, value) => {
if (!showAccordion) {
return
}

item.name = value
setItem(item)
handleValidation(item)
Expand Down

0 comments on commit ffe2666

Please sign in to comment.