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

Keyboard nav for extensions main screen #13176

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

aalves08
Copy link
Member

@aalves08 aalves08 commented Jan 22, 2025

Summary

Fixes #12785

Occurred changes and/or fixed issues

  • Add keyboard navigation for Extensions main screen (normal extensions interface + image catalog load -> check extensions menu)
  • Refactor focus traps to composables
  • Add focus traps to various dialogs/modals on Extensions screen
  • Improve LabeledInput accessibility

Technical notes summary

Areas or cases that should be tested

Areas which could experience regressions

Screenshot/Video

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR has a Milestone
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes

@aalves08 aalves08 marked this pull request as draft January 22, 2025 10:51
@aalves08 aalves08 force-pushed the 12785-key-nav-extensions branch 3 times, most recently from cbb6400 to 3d08265 Compare January 24, 2025 12:55
@aalves08 aalves08 force-pushed the 12785-key-nav-extensions branch from 491259a to da77f27 Compare January 27, 2025 18:12
@aalves08 aalves08 marked this pull request as ready for review January 28, 2025 11:09
@aalves08 aalves08 changed the title WIP: keyboard nav for extensions main screen Keyboard nav for extensions main screen Jan 28, 2025
@aalves08 aalves08 added this to the v2.11.0 milestone Jan 28, 2025
@aalves08 aalves08 requested a review from rak-phillip January 28, 2025 16:35
Comment on lines +103 to +107
created() {
if (this.triggerFocusTrap) {
watcherBasedSetupFocusTrap(() => this.modalVisibility, '.modal-container');
}
},
Copy link
Member

Choose a reason for hiding this comment

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

In pkg/rancher-components/src/components/Card/Card.vue, we do the following

  setup(props) {
    if (props.triggerFocusTrap) {
      basicSetupFocusTrap('#focus-trap-card-container');
    }

Is there any reason why we can't do the same here? It looks like we would be able to drop the modalVisibility prop if we were to achieve this.

@@ -1,8 +1,9 @@
<script lang="ts">
import { defineComponent, PropType } from 'vue';
import { createFocusTrap, FocusTrap } from 'focus-trap';
import { basicSetupFocusTrap } from '@shell/composables/focusTrap';
Copy link
Member

Choose a reason for hiding this comment

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

It's a common Vue convention for composable functions to start with use. I think that useFocusTrap would be a more idiomatic name for this function.

});
</script>

<template>
<div
ref="cardContainer"
id="focus-trap-card-container"
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason we can't stick with the ref? I think that it is preferred over an id when working with component instances.

Comment on lines +61 to +67
/**
* Modal visibility (used for focus-trap)
*/
modalVisibility: {
type: Boolean,
default: false,
},
Copy link
Member

Choose a reason for hiding this comment

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

The modalVisibility looks redundant to me.. Shouldn't modal instances be conditionally rendered already?

import { createFocusTrap, FocusTrap } from 'focus-trap';

export function basicSetupFocusTrap(containerSelector: string) {
let focusTrapInstance = {} as FocusTrap;
Copy link
Member

Choose a reason for hiding this comment

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

I think that we can just specify the type:

Suggested change
let focusTrapInstance = {} as FocusTrap;
let focusTrapInstance: FocusTrap;

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.

a11y: Fix keyboard navigation and focus display for Extensions grid view
2 participants