Skip to content

Commit

Permalink
feat: Remove useless code in NestedSelect
Browse files Browse the repository at this point in the history
This code added in this PR:
#1270

It doesn't seem/no longer useful, and degrades the UX a bit.

If the need to be covered by this code arises in the future,
we will consider better integration at that time.
  • Loading branch information
Merkur39 committed Apr 9, 2024
1 parent 8cf959e commit b88450c
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions react/NestedSelect/NestedSelect.jsx
@@ -1,4 +1,4 @@
import React, { useEffect, useState, useRef } from 'react'
import React, { useState, useRef } from 'react'
import PropTypes from 'prop-types'
import omit from 'lodash/omit'

Expand Down Expand Up @@ -36,20 +36,6 @@ const NestedSelect = ({
searchValue: '',
searchResult: []
})
const [unmounted, setUnmounted] = useState(false)

useEffect(() => {
return () => {
setUnmounted(true)
}
}, [])

const resetHistory = () => {
if (unmounted) {
return
}
setState(state => ({ ...state, history: [options] }))
}

const handleBack = () => {
const [item, ...newHistory] = state.history
Expand All @@ -66,16 +52,6 @@ const NestedSelect = ({

const handleSelect = item => {
onSelect(item)
// It is important to reset history if the NestedSelected is used
// multiple times in a row without being dismounted. For example
// if it displayed in Carousel that slides in the NestedSelect
// and slides it out on selection.
// But, we want in this case that the resetting does not happen
// while the animation is running.
// There is probably a better way to do this.
setTimeout(() => {
resetHistory()
}, 500)
}

const handleClickItem = item => {
Expand Down

0 comments on commit b88450c

Please sign in to comment.