Skip to content

Commit

Permalink
fix(Tile): ClickableTile should focus when no href prop (#15029)
Browse files Browse the repository at this point in the history
* fix(ClickableTile): focus when no href prop

If no href is defined, clickableTile should still be able to
gain focus. Also removes the duplicate onKeyDown call
which causes the callback to run twice, which is
undesirable when a user is trying to do something with
the enter/space key.

* docs: add alewitt2 to contributors
  • Loading branch information
alewitt2 authored Oct 26, 2023
1 parent ef00068 commit 754056f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
11 changes: 10 additions & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@
"contributions": [
"code",
"doc"
]
]
},
{
"login": "amanlajpal",
Expand All @@ -1297,6 +1297,15 @@
"contributions": [
"code"
]
},
{
"login": "alewitt2",
"name": "Alex Lewitt",
"avatar_url": "https://avatars.githubusercontent.com/u/48691328?v=4",
"profile": "https://github.com/alewitt2",
"contributions": [
"code"
]
}
],
"commitConvention": "none"
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,12 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md) and our
<td align="center"><a href="https://github.com/cordesmj"><img src="https://avatars.githubusercontent.com/u/7409239?v=4?s=100" width="100px;" alt=""/><br /><sub><b>cordesmj</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=cordesmj" title="Code">💻</a></td>
<td align="center"><a href="https://med-aziz-chebbi.web.app/"><img src="https://avatars.githubusercontent.com/u/60013060?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aziz Chebbi</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=azizChebbi" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/misiekhardcore"><img src="https://avatars.githubusercontent.com/u/58469680?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Michał Konopski</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=misiekhardcore" title="Code">💻</a></td>
<td align="center"><a href="https://omkarajagunde.web.app/"><img src="https://avatars.githubusercontent.com/u/50138744?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Omkar Ajagunde</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=omkarajagunde" title="Code">💻</a></td>
<td align="center"><a href="https://omkarajagunde.web.app/"><img src="https://avatars.githubusercontent.com/u/50138744?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Omkar Ajagunde</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=omkarajagunde" title="Code">💻</a> <a href="https://github.com/carbon-design-system/carbon/commits?author=omkarajagunde" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/amanlajpal"><img src="https://avatars.githubusercontent.com/u/42869088?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aman Lajpal</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=amanlajpal" title="Code">💻</a> <a href="https://github.com/carbon-design-system/carbon/commits?author=amanlajpal" title="Documentation">📖</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/allisonishida"><img src="https://avatars.githubusercontent.com/u/22247062?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Allison Ishida</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=allisonishida" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/alewitt2"><img src="https://avatars.githubusercontent.com/u/48691328?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alex Lewitt</b></sub></a><br /><a href="https://github.com/carbon-design-system/carbon/commits?author=alewitt2" title="Code">💻</a></td>
</tr>
</table>

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/components/Tile/Tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export const ClickableTile = React.forwardRef<
evt?.persist?.();
if (matches(evt, [keys.Enter, keys.Space])) {
setIsSelected(!isSelected);
onKeyDown(evt);
}
onKeyDown(evt);
}
Expand All @@ -190,6 +189,7 @@ export const ClickableTile = React.forwardRef<
<Link
className={classes}
href={href}
tabIndex={!href && !disabled ? 0 : undefined}
onClick={!disabled ? handleOnClick : undefined}
onKeyDown={handleOnKeyDown}
ref={ref}
Expand Down

0 comments on commit 754056f

Please sign in to comment.