S
S
Siv Nefzer2021-06-02 11:12:11
React
Siv Nefzer, 2021-06-02 11:12:11

React. how not to close DropDown after menu click?

I'm using the airframe library, the UncontrolledDropdown component. After the action with the items (change the checkbox), the list closes, I can't make it stay open.

<UncontrolledDropdown className="ml-auto  mt-1">
              <DropdownToggle color="secondary">
                <FontAwesomeIcon icon="bars" fixedWidth />
              </DropdownToggle>
              <DropdownMenu right positionFixed>
                <DropdownItem name="simpleLine" id="simpleLine" onClick={this.handleChangeCheck}>
                  <CustomInput
                    type="checkbox"
                    name="simpleLine"
                    id="simpleLine"
                    defaultChecked={graphState.simpleLine}>
                    Статистика выполнения заказов
                  </CustomInput>
                </DropdownItem>
                <DropdownItem name="maket802" id="maket802" onClick={this.handleChangeCheck}>
                  <CustomInput
                    type="checkbox"
                    name="maket"
                    id="maket802"
                    defaultChecked={graphState.maket}>
                    802 Макет
                  </CustomInput>
                </DropdownItem>
</DropdownMenu>
</UncontrolledDropdown>

  handleChangeCheck(event) {
    event.preventDefault();
    let graphState = this.state.graphState;
    const name = event.currentTarget.name;
    if (name === 'simpleLine') graphState.simpleLine = !graphState.simpleLine;
    if (name === 'maket') graphState.maket802 = !graphState.maket;
    this.props.onChangeGraphState(event, graphState);
    event.stopPropagation();
  }


props refers to the handler for the parent
handleChangeGraphState(event, newState) {
    event.preventDefault();
    localStorage.setItem('graph', JSON.stringify(newState));
    this.setState({ graph: newState });
    event.stopPropagation();
  }

Please tell me how to solve this problem.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question