Skip to content

Provide interface to isOpen variable #404

@kosanna

Description

@kosanna

Are you reporting a bug?

No.

Are you making a feature request?

Yes. Happy to PR it.

  • Please describe your use case from user journey point of view, e.g.:

When user sees suggestions, for example show overlay around dropdown and label (or do something else crazy), when used doesn't see suggestions, hide overlay.

  • If you have ideas how to extend the Autosuggest API to support your new feature, please share!

Add isOpen to component's state, make component accept onDropdownOpen and onDropdownClose callback functions and do state update

componentWillUpdate(nextProps, nextState) {
    const {
      onDropdownOpen,
      onDropdownClose
    } = this.props;
    const { isFocused, isCollapsed } = nextState;
    const willRenderSuggestions = this.willRenderSuggestions(this.props);
    const isOpen =
      alwaysRenderSuggestions ||
      (isFocused && !isCollapsed && willRenderSuggestions);

    if (this.state.isOpen != isOpen) {
      this.setState({ isOpen });

      if (isOpen) {
        onDropdownOpen();
      } else {
        onDropdownClose();
      }
    }

Something like that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions