Skip to content

Commit

Permalink
fix(component-header): change onFocus to onClick for type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
davidornelas11 committed Oct 2, 2024
1 parent faf982a commit 9634a97
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 10 deletions.
3 changes: 1 addition & 2 deletions packages/component-header/src/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ import { ButtonWrapper } from "./index.styles";
* @returns {JSX.Element}
*/

const Button = ({ href, color, text, classes, onClick, onFocus }) => {
const Button = ({ href, color, text, classes, onClick }) => {
return (
<ButtonWrapper
href={href}
{...(!href ? { tabIndex: 0 } : {})}
className={`button-${color} ${classes ?? ""}`}
onClick={onClick}
onFocus={onFocus}
>
{text}
</ButtonWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const LinkItem = ({ link, dropdownName, handleLinkEvent }) => (
href={link.href}
onClick={e => handleLinkEvent(e, link)}
onKeyDown={e => handleLinkEvent(e, link)}
onFocus={() => trackGAEvent({ text: link.text, component: dropdownName })}
onClick={() => trackGAEvent({ text: link.text, component: dropdownName })}
>
{link.text}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ const NavItem = ({ link, setItemOpened, itemOpened }) => {
};

const handleKeyDown = e => {
if (!link.items && link.href) return;
if (!link.items && link.href) {
trackGAEvent({ ...LINK_DEFAULT_PROPS, text: link.text });
return;
};
const { key } = e;
const navigableKeys = [
"ArrowUp",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Partner = () => {
</a>
<a
href={asuLogo?.brandLink ?? "https://asu.edu"}
onFocus={() => trackGAEvent({ text: "asu logo" })}
onClick={() => trackGAEvent({ text: "asu logo" })}
>
<img
className="vert"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Title = () => {
<a
className={`subunit-name ${active ? "active" : ""}`}
href={baseUrl}
onFocus={() =>
onClick={() =>
trackGAEvent({
event: "link",
action: "click",
Expand Down Expand Up @@ -83,7 +83,7 @@ const Title = () => {
<a
className={`title-subunit-name ${active ? "active" : ""}`}
href={baseUrl}
onFocus={() => trackGAEvent({ text: title })}
onClick={() => trackGAEvent({ text: title })}
title={`${title} home page`}
>
{title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const ButtonPropTypes = {
href: PropTypes.string.isRequired,
classes: PropTypes.string,
onClick: PropTypes.func,
onFocus: PropTypes.func,
onClick: PropTypes.func,
};

const NavTreePropTypes = PropTypes.shape({
Expand Down
2 changes: 1 addition & 1 deletion packages/component-header/src/core/models/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @property {string} text
* @property {string} [classes]
* @property {function} [onClick]
* @property {function} [onFocus]
* @property {function} [onClick]
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/component-header/types/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface Button {
text: string;
classes?: string;
onClick?: () => void;
onFocus?: () => void;
onClick?: () => void;
}

export interface NavTreeProps {
Expand Down

0 comments on commit 9634a97

Please sign in to comment.