scalajs-react-components icon indicating copy to clipboard operation
scalajs-react-components copied to clipboard

Dropdown(onSelect) of elementalui seems broken

Open bijancn opened this issue 7 years ago • 1 comments

The case class

case class Dropdown(alignRight: js.UndefOr[Boolean] = js.undefined,
                    buttonHasDisclosureArrow: js.UndefOr[Boolean] = js.undefined,
                    buttonLabel: js.UndefOr[String] = js.undefined,
                    buttonType: js.UndefOr[ButtonType] = js.undefined,
                    className: js.UndefOr[String] = js.undefined,
                    isOpen: js.UndefOr[Boolean] = js.undefined,
                    children: js.UndefOr[Boolean] = js.undefined,
                    items: js.Array[DropdownMenuItem],
                    onSelect: js.UndefOr[ReactEventFromHtml => Callback] = js.undefined)

offers an onSelect option and I would have expected that it works similar to the onChange of FormInput or the onChange of FormSelect, i.e. I can put a handler in there to change my state of items. However, if I add a handler I see that

    private def handler: ReactEventFromHtml => Callback = event => {
      println(s"event = ${event}"); submit(event)
    }

gives

event = undefined

so I have a hard time using that. I only can see in react dropdown examples that people are using onClick and not onSelect (like here e.g. https://github.com/reactstrap/reactstrap/issues/559). Is this maybe just the wrong attribute?

bijancn avatar Mar 05 '18 13:03 bijancn

Correction. onSelect is indeed used by elemental UI. Maybe the types are not correct? I don't understand why I get undefined https://github.com/elementalui/elemental/blob/master/src/components/Dropdown.js#L22 .

bijancn avatar Mar 05 '18 13:03 bijancn