Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

onClick handler does not work properly for List component #680

Closed
johannao76 opened this issue Jan 3, 2019 · 0 comments
Closed

onClick handler does not work properly for List component #680

johannao76 opened this issue Jan 3, 2019 · 0 comments
Labels
vsts Paired with ticket in vsts

Comments

@johannao76
Copy link
Contributor

Bug Report

Steps

Create a List component using shorthand props for the items list. Specify an onClick handler for each item.

Expected Result

When an item is clicked on, the onClick handler is called and the item is passed in as the second argument (as it works with menu items currently).

Actual Result

The item is not passed to the callback

Version

0.13.1

Testcase

import React from 'react'
import { List, Image } from '@stardust-ui/react'

const itemSelected = (evt, item) => {
  alert(item.index);
}

const items = [
  {
    key: 'irving',
    media: <Image src="public/images/avatar/small/matt.jpg" avatar />,
    header: 'Irving Kuhic',
    headerMedia: '7:26:56 AM',
    content: 'Program the sensor to the SAS alarm through the haptic SQL card!',
    onClick: itemSelected
  },
  {
    key: 'skyler',
    media: <Image src="public/images/avatar/small/steve.jpg" avatar />,
    header: 'Skyler Parks',
    headerMedia: '11:30:17 PM',
    content: 'Use the online FTP application to input the multi-byte application!',
    onClick: itemSelected
  },
  {
    key: 'dante',
    media: <Image src="public/images/avatar/small/nom.jpg" avatar />,
    header: 'Dante Schneider',
    headerMedia: '5:22:40 PM',
    content: 'The GB pixel is down, navigate the virtual interface!',
    onClick: itemSelected
  },
]

const selection = knobs => (knobs === undefined ? true : knobs.selection)

const ListExampleSelection = ({ knobs }) => <List selection={selection(knobs)} items={items} />

export default ListExampleSelection

Example that works using Menu:

import { Menu } from '@stardust-ui/react'

const itemSelected = (evt, menuItem) => {
  alert(menuItem.index);
}

const items = [
  { key: 'editorials', content: 'Editorials', onClick: itemSelected},
  { key: 'review', content: 'Reviews', onClick: itemSelected },
  { key: 'events', content: 'Upcoming Events', onClick: itemSelected },
];

const MenuExampleUnderlinedPrimary = () => (
  <Menu defaultActiveIndex={0} items={items} underlined primary />
)

export default MenuExampleUnderlinedPrimary
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
vsts Paired with ticket in vsts
Projects
None yet
Development

No branches or pull requests

2 participants