Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EuiSuperSelect into Modal can't change value #1495

Closed
frankjar opened this issue Jan 30, 2019 · 1 comment · Fixed by #1550
Closed

EuiSuperSelect into Modal can't change value #1495

frankjar opened this issue Jan 30, 2019 · 1 comment · Fixed by #1550
Assignees
Labels

Comments

@frankjar
Copy link

frankjar commented Jan 30, 2019

Hi,
i'm trying to use EuiSuperSelect into a EuiModal and the value change doesn't work : no change at all.

Here is the code to duplicate the issue :

import React, { Component, Fragment } from "react";
import {
  EuiOverlayMask,
  EuiModal,
  EuiModalHeader,
  EuiModalHeaderTitle,
  EuiModalBody,
  EuiModalFooter,
  EuiButtonEmpty,
  EuiSuperSelect,
  EuiSpacer,
  EuiText
} from "@elastic/eui";

 class SuperSelectEncapsulation extends Component {
  constructor(props) {
    super(props);

    this.options = [
      {
        value: "option_one",
        inputDisplay: "Option one",
        dropdownDisplay: (
          <Fragment>
            <strong>Option one</strong>
            <EuiSpacer size="xs" />
            <EuiText size="s" color="subdued">
              <p className="euiTextColor--subdued">
                Has a short description giving more detail to the option.
              </p>
            </EuiText>
          </Fragment>
        )
      },
      {
        value: "option_two",
        inputDisplay: "Option two",
        dropdownDisplay: (
          <Fragment>
            <strong>Option two</strong>
            <EuiSpacer size="xs" />
            <EuiText size="s" color="subdued">
              <p className="euiTextColor--subdued">
                Has a short description giving more detail to the option.
              </p>
            </EuiText>
          </Fragment>
        )
      },
      {
        value: "option_three",
        inputDisplay: "Option three",
        dropdownDisplay: (
          <Fragment>
            <strong>Option three</strong>
            <EuiSpacer size="xs" />
            <EuiText size="s" color="subdued">
              <p className="euiTextColor--subdued">
                Has a short description giving more detail to the option.
              </p>
            </EuiText>
          </Fragment>
        )
      }
    ];

    this.state = {
      value: ""
    };
  }

  onChange = value => {
    this.setState({ value });
  };

  render() {
    return (
      <EuiSuperSelect
        options={this.options}
        valueOfSelected={this.state.value}
        onChange={this.onChange}
        itemLayoutAlign="top"
        hasDividers
      />
    );
  }
}

const TestSuperSelect = () => {
  return (
      <EuiOverlayMask>
      <EuiModal>
        <EuiModalBody>
          <SuperSelectEncapsulation />
        </EuiModalBody>
      </EuiModal>
    </EuiOverlayMask>
  );
};

export default TestSuperSelect

I'm using the EuiSuperSelect example founded here https://elastic.github.io/eui/#/forms/superselect .

Note that the EuiSelect works fine.

Do you have an idea? thx a lot

  • React v16.7.0
  • @elastic/eui : 6.7.4
  • react scripts : 2.1.3
@chandlerprall chandlerprall self-assigned this Jan 30, 2019
@chandlerprall
Copy link
Contributor

EuiModal's focus trap is preventing the super select's option box from receiving events as it is rendered at the bottom of the DOM through a portal. I tested this with EuiComboBox as well, and selecting a combo box option with the mouse does not work for the same reason, though keyboard navigation of options works as that selection/focus is simulated; keyboard navigation of the super select options does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants