Skip to content

Not working with component rendering a <React.Fragment> or an array #80

@lpillonel

Description

@lpillonel

When I want to use react-keydown with a component rendering an array or a React.Fragment, it's working only if i click on the first item of the array (respectively first child of the Fragment).

import React, { PureComponent, Fragment } from 'react'
import keydown from 'react-keydown'

import TreeViewHeader from './TreeViewHeader'
import TreeViewComponent from './TreeView'

export default class TreeView extends PureComponent {
  @keydown('up')
  selectPreviousRow (event) {
    console.log('select previous row', event)
  }

  render () {
    return (
      <Fragment>
        <TreeViewHeader />
        <TreeViewComponent />
      </Fragment>
    )
  }
}

In this example, it's working only if I click on the first item. I tried to swipe TreeViewHeader and TreeViewComponent, and then it's working only if I click on TreeViewComponent

For now as a workaround I wrap all inside a div and it's working, but I would prefer to use a Fragment.

Thanks for your help,

Luca

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