[Bug]: onClick doesn't work on a HeaderMenuItem if there is no href prop #19436
Labels
component: ui-shell
package: @carbon/react
@carbon/react
role: dev 🤖
severity: 3
https://ibm.biz/carbon-severity
type: bug 🐛
Package
@carbon/react
Browser
Firefox, Safari, Chrome
Package version
1.81.0+
React version
v18.3.1 (also seen on v19)
Description
The
onClick
handler is not getting triggered for aHeaderMenuItem
if it does not have anhref
prop. This only happens from@carbon/react
1.81.0
onwards, and broke our existing usage which should trigger a function to pop up a dialog and not change the page.(Example adapted from #19401 which is similar but Safari-specific, and did have
href
prop I took out of my reproduction example)A workaround has been to provide an
href
prop, but as we don't want the page to reload/change, we've had to usepreventDefault()
in theonClick
function.Reproduction/example
https://stackblitz.com/edit/github-idy2xfcw-flabvycf?file=package.json
Steps to reproduce
@carbon/react
inpackage.json
down to1.80.0
and rerunSuggested Severity
Severity 3 = User can complete task, and/or has a workaround within the user experience of a given component.
Application/PAL
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: