Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uds 1793: Fix onclick in header navtree #1342

Merged
merged 6 commits into from
Sep 4, 2024
Merged

Uds 1793: Fix onclick in header navtree #1342

merged 6 commits into from
Sep 4, 2024

Conversation

davidornelas11
Copy link
Contributor

@davidornelas11 davidornelas11 commented Aug 13, 2024

Description

fixed navtree with onclick not getting called

  1. Add these props to a story navTree: [ { text: "Home", selected: false, onClick: () => { console.log("Home clicked"); } }, { text: "Test 1", selected: false, onClick: () => { console.log("Test 1 clicked"); } }, { text: "Fun", selected: false, onClick: () => { console.log("Test 2 clicked"); } } ], title: "Ira A. Fulton Schools of Engineering", parentOrg: "School of Computing, Informatics, and Decisions Systems Engineering", parentOrgUrl: "https://engineering.asu.edu", loggedIn: false,
  2. Check to make sure the oncall is called and that it is keyboard navigable

Links

FOR APPROVERS

@davidornelas11 davidornelas11 requested a review from a team as a code owner August 13, 2024 21:56
Copy link
Member

@mlsamuelson mlsamuelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with sublinks and they're not clickable by keyboard or mouse. The tabindex="0" isn't applying to the sublinks also, so they aren't focusable.

Per @scott-williams-az , it appears sublinks never supported onClick behaviors.

code I used for navTree to illustrate this:

const myNavTree = [
  {
    text: "Home",
    selected: false,
    onClick: () => {
      console.log("Home clicked");
    },
  },
  {
    text: "Test 1",
    selected: false,
    onClick: () => {
      console.log("Test 1 clicked");
    },
  },
  {
    text: "Fun",
    selected: false,
    onClick: () => {
      console.log("Test 2 clicked");
    },
  },
  {
    text: "Link option 1",
    href: "#",
    items: [
      [
        {
          text: "Sublink 1",
          selected: false,
          onClick: () => {
            console.log("Sublink 1 clicked");
          },
        },
        {
          href: "https://www.asu.edu/",
          text: "Sublink 2",
        },
      ],
    ],
  },
];

@davidornelas11
Copy link
Contributor Author

I tested with sublinks and they're not clickable by keyboard or mouse. The tabindex="0" isn't applying to the sublinks also, so they aren't focusable.

Per @scott-williams-az , it appears sublinks never supported onClick behaviors.

code I used for navTree to illustrate this:

const myNavTree = [
  {
    text: "Home",
    selected: false,
    onClick: () => {
      console.log("Home clicked");
    },
  },
  {
    text: "Test 1",
    selected: false,
    onClick: () => {
      console.log("Test 1 clicked");
    },
  },
  {
    text: "Fun",
    selected: false,
    onClick: () => {
      console.log("Test 2 clicked");
    },
  },
  {
    text: "Link option 1",
    href: "#",
    items: [
      [
        {
          text: "Sublink 1",
          selected: false,
          onClick: () => {
            console.log("Sublink 1 clicked");
          },
        },
        {
          href: "https://www.asu.edu/",
          text: "Sublink 2",
        },
      ],
    ],
  },
];

I cleaned up the dropdown component a bit and added the onClick event

@mlsamuelson
Copy link
Member

Screenshot 2024-08-14 at 8 35 27 AM

@mlsamuelson
Copy link
Member

mlsamuelson commented Aug 14, 2024

Circular dependency: DropdownItem/index.js imports from NavItem/index.js and that in turn imports from DropdownItem/index.js.

The DropdownItem component file is just pulling in the LINK_DEFAULT_PROPS, and we're getting other eslint errors about the props, so perhaps the DropdownItem component file just needs to do its own thing for the link props?

Copy link
Member

@mlsamuelson mlsamuelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issues resolved! Thanks, @davidornelas11

@mlsamuelson mlsamuelson merged commit 98989eb into dev Sep 4, 2024
1 check passed
@mlsamuelson mlsamuelson deleted the UDS-1793 branch September 4, 2024 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants