shopify polais subnavigationitems onclick doesn't work

Highlighted
New Member
1 0 0

Issue summary

subnavigationitems onclick doesn't work

Expected behavior

i create subnavigation items, but when i click on subnavigation item, the onClick method do not work, it must print 3434 on screen, but nothing happen

code :

import React from 'react';
import {Navigation} from '@shopify/polaris';
import {HomeMajorMonotone, OrdersMajorTwotone, ProductsMajorTwotone} from '@shopify/polaris-icons';

export default class App extends React.Component {

hey(e){
console.log(3434)
}

render() {
return (

<Navigation.Section
items={[
{
url: '/',
label: 'Home',
icon: HomeMajorMonotone,
subNavigationItems: [
{
url: '/',
label: 'home 2',
onClick: this.hey
}
],
onClick: this.hey
},
{
url: '/orders',
label: 'Orders',
icon: OrdersMajorTwotone,
badge: '15',
},
{
url: '/hey',
label: 'Products',
icon: ProductsMajorTwotone,
},
]}
/>

);
}
}

codesandbox url

https://codesandbox.io/s/trusting-lake-5xl3g?fontsize=14&hidenavigation=1&theme=dark

Specifications

  • Are you using the React components? (Y/N): Y
  • Polaris version number: 4.23
  • Browser: chrome
  • Device: pc
  • Operating System: windows 10
0 Likes
Highlighted
Shopify Staff
Shopify Staff
1004 131 148

Looks like a fix is in the works: https://github.com/Shopify/polaris-react/pull/2640

0 Likes