Skip to content

Commit

Permalink
Ensured and added keyboard navigation for public facing components
Browse files Browse the repository at this point in the history
  • Loading branch information
qhanson55 committed Dec 20, 2024
1 parent 481a786 commit 59ed470
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ const confirmSubmit = () => {
<div :class="{ 'teleport-container': true, '--open': showTab }">
<div
class="assistance-tab pb-3 pt-3 pr-1 pl-1"
tabindex="0"
@click="showTab = !showTab"
@keydown.enter.prevent="showTab = !showTab"
@keydown.space.prevent="showTab = !showTab"
>
<div class="tab-text">Assistance</div>
<font-awesome-icon
Expand Down Expand Up @@ -127,6 +130,11 @@ const confirmSubmit = () => {
width: 20rem;
}
:deep(.assistance-tab:focus-visible) {
outline: 0.25rem solid $app-hover;
outline-offset: 0.125rem;
}
.assistance-tab {
cursor: pointer;
position: absolute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import {
SubmissionType
} from '@/utils/enums/housing';
import { confirmationTemplateSubmission } from '@/utils/templates';
import { omit } from '@/utils/utils';
import { getHTMLElement, omit } from '@/utils/utils';
import type { Ref } from 'vue';
import type { AutoCompleteCompleteEvent } from 'primevue/autocomplete';
Expand Down Expand Up @@ -1498,6 +1498,7 @@ onBeforeMount(async () => {
values.permits?.hasAppliedProvincialPermits === BasicResponse.UNSURE

Check warning on line 1498 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute "ref" should go before "class"

Check warning on line 1498 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute "ref" should go before "class"

Check warning on line 1498 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (22.x)

Attribute "ref" should go before "class"
"
class="col-12"
ref="appliedPermitsContainer"

Check warning on line 1501 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute "ref" should go before "class"

Check warning on line 1501 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute "ref" should go before "class"

Check warning on line 1501 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (22.x)

Attribute "ref" should go before "class"
>
<div class="mb-2">
<span class="app-primary-color">
Expand Down Expand Up @@ -1565,7 +1566,16 @@ onBeforeMount(async () => {
permitTypeId: undefined,
trackingId: undefined,
submittedDate: undefined
})
});
nextTick(() => {
const addedPermit = getHTMLElement(
$refs.appliedPermitsContainer as HTMLElement,
'div[name*=\'permitTypeId\'] span[role=\'combobox\']'
);
if (addedPermit) {
addedPermit.focus();
}
});
"
>
<font-awesome-icon
Expand Down Expand Up @@ -1626,7 +1636,10 @@ onBeforeMount(async () => {
<div class="col-12">
<Card class="no-shadow">
<template #content>

Check warning on line 1638 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute "ref" should go before "class"

Check warning on line 1638 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute "ref" should go before "class"

Check warning on line 1638 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (22.x)

Attribute "ref" should go before "class"
<div class="formgrid grid">
<div
class="formgrid grid"
ref="investigatePermitsContainer"

Check warning on line 1641 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Attribute "ref" should go before "class"

Check warning on line 1641 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Attribute "ref" should go before "class"

Check warning on line 1641 in frontend/src/components/housing/submission/SubmissionIntakeForm.vue

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (22.x)

Attribute "ref" should go before "class"
>
<div
v-for="(permit, idx) in fields"
:key="idx"
Expand Down Expand Up @@ -1665,9 +1678,16 @@ onBeforeMount(async () => {
v-if="editable"
class="w-full flex justify-content-center font-bold"
@click="
push({
permitTypeId: undefined
})
push({ permitTypeId: undefined });
nextTick(() => {
const newPermitDropdown = getHTMLElement(
$refs.investigatePermitsContainer as HTMLElement,
'div[name*=\'investigatePermits\'] span[role=\'combobox\']'
);
if (newPermitDropdown) {
newPermitDropdown.focus();
}
});
"
>
<font-awesome-icon
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/components/layout/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ const { t } = useI18n();
&:hover {
text-decoration: underline;
}
&:focus {
outline: none;
}
&:visited {
color: var(--text-color);
}
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,27 @@ export function getFilenameAndExtension(filename: string): { filename: string; e
}
}

/**
* @function getHTMLElement
* Return element that is inside a given element/container
* @param {HTMLElement} container contains element to be found
* @param {string} query query used to find said element
* @param {number} index index of element that is desired, if undefined get only/last element
* @returns {HTMLElement | null} HTMLElement or null if no element/not an html element
*/
export function getHTMLElement(container: HTMLElement, query: string, index?: number): HTMLElement | null {
console.log(container);

Check warning on line 126 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Unexpected console statement

Check warning on line 126 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Unexpected console statement

Check warning on line 126 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (22.x)

Unexpected console statement

Check warning on line 126 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Unexpected console statement

Check warning on line 126 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Unexpected console statement

Check warning on line 126 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (22.x)

Unexpected console statement
const elements = container.querySelectorAll(query);
console.log(elements);

Check warning on line 128 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Unexpected console statement

Check warning on line 128 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Unexpected console statement

Check warning on line 128 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (22.x)

Unexpected console statement

Check warning on line 128 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (18.x)

Unexpected console statement

Check warning on line 128 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (20.x)

Unexpected console statement

Check warning on line 128 in frontend/src/utils/utils.ts

View workflow job for this annotation

GitHub Actions / Unit Tests (Frontend) (22.x)

Unexpected console statement
const length = elements.length;

if (length === 0) return null;

const element = index !== undefined ? elements[index] : elements[length - 1];

return element instanceof HTMLElement ? element : null;
}

/**
* @function isDebugMode
* Checks if the app is currently running in debug mode
Expand Down

0 comments on commit 59ed470

Please sign in to comment.