2

I have a simple React Select as content prop in a Semantic UI React Popover component. I am constrained by each of the package versions inside the project (available in the following codesandbox https://codesandbox.io/s/wy194rz908):

  • React: ~15.5.0
  • ReactDOM: ~15.5.0
  • React-Select: ^2.1.1
  • Semantic UI React: 0.71.5

As you can see, the React Select options closes when a selection is done.

On the other hand, I found that updating React, React-DOM and SemanticUI to their latest versions make the feature work. As you can see, the selection is done and the Select options do not fold (available in the following codesandbox https://codesandbox.io/s/6y14qyykk3).

As I can not update update the React and SUIR, what workaround should I follow in order to make this work?

Thanks!

2 Answers 2

2

You have to use a Controlled Popup Component, as stated in docs:

import React from 'react'
import { Button, Popup } from 'semantic-ui-react'

class PopupExampleContextControlled extends React.Component {
  state = {}

  toggle = () => this.setState({ open: !this.state.open })

  handleRef = node => this.setState({ node })

  render() {
    const { node, open } = this.state
    return (
      <div>
        <Button content='Open controlled Popup' onClick={this.toggle} />
        <Popup context={node} content='Hello' position='top center' open={open} />
        ---------->
        <strong ref={this.handleRef}>here</strong>
      </div>
    )
  }
}

export default PopupExampleContextControlled

In this way you can control when popup opens and closes.

Sign up to request clarification or add additional context in comments.

Comments

0

I am controlling the Popup using the open prop available through its props api. I change its state from true to false when clicking the caret down icon button.

Solution: https://codesandbox.io/s/rmoxx98qkn

2 Comments

If you click in the textbox then outside textbox popup closes anyway
yeah, I still need to fix where to set the onBlur

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.