Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Lot / DP Numbers display for NSW Point V3 form element
- disabled on `Clickable` not disabling click function

## [9.1.0] - 2026-02-23

Expand Down
22 changes: 13 additions & 9 deletions src/components/Clickable.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
import * as React from 'react'
import clsx from 'clsx'

export function Clickable(
props: React.ComponentProps<'div'> & {
disabled?: boolean
},
) {
export function Clickable({
disabled,
onClick,
...props
}: React.ComponentProps<'div'> & {
disabled?: boolean
}) {
const ref = React.useRef<HTMLDivElement>(null)
return (
<div
{...props}
onClick={disabled ? undefined : onClick}
role="button"
tabIndex={props.disabled ? -1 : 0}
tabIndex={disabled ? -1 : 0}
ref={ref}
onKeyDown={(event) => {
if (disabled) return
if (
ref.current === event.target &&
(event.key === 'Enter' || event.key === ' ')
) {
props.onClick?.(
onClick?.(
event as unknown as React.MouseEvent<HTMLDivElement, MouseEvent>,
)
}
props.onKeyDown?.(event)
}}
className={clsx(props.className, {
'is-clickable': !props.disabled,
'is-clickable': !disabled,
})}
aria-disabled={props.disabled}
aria-disabled={disabled}
/>
)
}