Skip to content

Direction prop doesn't work #102

@dFelinger

Description

@dFelinger

Setting direction prop makes dropdown not showing, because in AutocompleteDropdownContext direction is undefined.

In index.js direction sets from prop, but in AutocompleteDropdownContext direction is still undefined, because it not passes to context:

const {
  content,
  setContent,
  activeInputRef,
  direction = props.direction,
  setDirection
} = useContext(AutocompleteDropdownContext)

Without direction prop it sets to context on open:

const open = async () => {
  if (!props.direction) {
    await calculateDirection()
  }

  setIsOpened(true)
}

That's why we need to call setDirection in both cases like this or something:

const open = async () => {
  if (props.direction) {
    setDirection(props.direction)
  } else {
    await calculateDirection()
  }

  setIsOpened(true)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions