Skip to content

Commit

Permalink
#923: rename a11YNotificationEnabled to a11YScreenreaderModeEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
lehju committed Jun 3, 2024
1 parent 28cb0f3 commit 7074941
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
Screenreader Optimierung
<v-switch
:aria-label="
a11YNotificationEnabled()
a11YScreenreaderModeEnabled()
? 'ist aktiviert, deaktivieren mit Entertaste'
: 'ist deaktiviert, aktivieren mit Entertaste'
"
:input-value="a11YNotificationEnabled()"
:input-value="a11YScreenreaderModeEnabled()"
class="ml-2"
dense
>
Expand Down Expand Up @@ -88,7 +88,12 @@ export default defineComponent({
emits: ["openKeyBindingsDialoge", "closeKeyBindingsDialoge"],
setup: (components, {emit}) => {
const theme = useTheme();
const {isHighContrastModeEnabled, setHighContrastModeEnabled, a11YNotificationEnabled, setA11YNotificationEnabled} =
const {
isHighContrastModeEnabled,
setHighContrastModeEnabled,
a11YScreenreaderModeEnabled,
setA11YScreenreaderModeEnabled
} =
useAccessibility();
emit("openKeyBindingsDialoge");
Expand All @@ -105,14 +110,14 @@ export default defineComponent({
};
const changeA11YNotificationMode = () => {
const isEnabled = a11YNotificationEnabled();
setA11YNotificationEnabled(!isEnabled);
const isEnabled = a11YScreenreaderModeEnabled();
setA11YScreenreaderModeEnabled(!isEnabled);
};
return {
changeMode,
isHighContrastModeEnabled,
a11YNotificationEnabled,
a11YScreenreaderModeEnabled,
changeA11YNotificationMode
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ export default defineComponent({
const errorMessage = ref("");
const currentSearch = ref("");
const a11YNotificationEnabled = useAccessibility().a11YNotificationEnabled;
const a11YScreenreaderModeEnabled = useAccessibility().a11YScreenreaderModeEnabled;
const screenreaderMode = computed(() => a11YNotificationEnabled());
const screenreaderMode = computed(() => a11YScreenreaderModeEnabled());
const autocompletion = ref();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ export default defineComponent({
const noDataText = ref<string>("Tippen, um Suche zu starten");
const a11YNotificationEnabled = useAccessibility().a11YNotificationEnabled;
const a11YScreenreaderModeEnabled = useAccessibility().a11YScreenreaderModeEnabled;
const screenreaderMode = computed(() => a11YNotificationEnabled());
const screenreaderMode = computed(() => a11YScreenreaderModeEnabled());
watch(searchText, (newValue) => {
searchUsersBySearchString(newValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export enum MessageType {
}

export const useNotification = (): NotificationContext => {
const { a11YNotificationEnabled } = useAccessibility();
const { a11YScreenreaderModeEnabled } = useAccessibility();
const messageText = ref<string | undefined>(undefined);
const location = ref<RawLocation | undefined>();
const snackbarVisible = ref<boolean>(false);
Expand All @@ -42,7 +42,7 @@ export const useNotification = (): NotificationContext => {
location.value = targetLocation;
messageType.value = type;

if (!a11YNotificationEnabled()) {
if (!a11YScreenreaderModeEnabled()) {
router.push(targetLocation);
snackbarVisible.value = true;
} else if (type === MessageType.SUCCESS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,51 @@ describe("accessibility", () => {
it("should return current value if high contrast mode is set to false", () => {
const state: AccessibilityState = {
highContrastModeEnabled: false,
a11YNotificationEnabled: false,
a11YScreenreaderModeEnabled: false,
};
const result = accessibility.getters.isHighContrastModeEnabled(state);
expect(result).toBeFalsy();
});
it("should return current value if high contrast mode is set to true", () => {
const state: AccessibilityState = {
highContrastModeEnabled: true,
a11YNotificationEnabled: false,
a11YScreenreaderModeEnabled: false,
};
const result = accessibility.getters.isHighContrastModeEnabled(state);
expect(result).toBeTruthy();
});
it("should return default value false if no value is set", () => {
const state: AccessibilityState = {
highContrastModeEnabled: undefined,
a11YNotificationEnabled: undefined,
a11YScreenreaderModeEnabled: undefined,
} as any; // so that we can set value to undefined
const result = accessibility.getters.isHighContrastModeEnabled(state);
expect(result).toBeFalsy();
});
});
describe("getters:isA11YNotificationEnabled", () => {
describe("getters:isA11YScreenreaderModeEnabled", () => {
it("should return current value if a11 notification is set to false", () => {
const state: AccessibilityState = {
highContrastModeEnabled: false,
a11YNotificationEnabled: false,
a11YScreenreaderModeEnabled: false,
};
const result = accessibility.getters.isA11YNotificationEnabled(state);
const result = accessibility.getters.isA11YScreenreaderModeEnabled(state);
expect(result).toBeFalsy();
});
it("should return current value if a11 notification is set to true", () => {
const state: AccessibilityState = {
highContrastModeEnabled: false,
a11YNotificationEnabled: true,
a11YScreenreaderModeEnabled: true,
};
const result = accessibility.getters.isA11YNotificationEnabled(state);
const result = accessibility.getters.isA11YScreenreaderModeEnabled(state);
expect(result).toBeTruthy();
});
it("should return default value false if no value is set", () => {
const state: AccessibilityState = {
highContrastModeEnabled: undefined,
a11YNotificationEnabled: undefined,
a11YScreenreaderModeEnabled: undefined,
} as any; // so that we can set value to undefined
const result = accessibility.getters.isA11YNotificationEnabled(state);
const result = accessibility.getters.isA11YScreenreaderModeEnabled(state);
expect(result).toBeFalsy();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { useStore } from "../../hooks/store";

export interface AccessibilityState {
highContrastModeEnabled: boolean;
a11YNotificationEnabled: boolean;
a11YScreenreaderModeEnabled: boolean;
}

const defaultAccessibilityState: AccessibilityState = {
highContrastModeEnabled: false,
a11YNotificationEnabled: false,
a11YScreenreaderModeEnabled: false,
};

export const accessibility = {
Expand All @@ -19,25 +19,27 @@ export const accessibility = {
? state.highContrastModeEnabled
: defaultAccessibilityState.highContrastModeEnabled;
},
isA11YNotificationEnabled: (state: AccessibilityState): boolean => {
return state.a11YNotificationEnabled !== undefined
? state.a11YNotificationEnabled
: defaultAccessibilityState.a11YNotificationEnabled;
isA11YScreenreaderModeEnabled: (state: AccessibilityState): boolean => {
return state.a11YScreenreaderModeEnabled !== undefined
? state.a11YScreenreaderModeEnabled
: defaultAccessibilityState.a11YScreenreaderModeEnabled;
},
},
mutations: {
setHighContrastModeEnabled: (state: AccessibilityState, enabled: boolean) =>
(state.highContrastModeEnabled = enabled),
setA11YNotificationEnabled: (state: AccessibilityState, enabled: boolean) =>
(state.a11YNotificationEnabled = enabled),
setA11YScreenreaderModeEnabled: (
state: AccessibilityState,
enabled: boolean
) => (state.a11YScreenreaderModeEnabled = enabled),
},
};

export interface Accessibility {
isHighContrastModeEnabled: () => boolean;
setHighContrastModeEnabled: (value: boolean) => void;
a11YNotificationEnabled: () => boolean;
setA11YNotificationEnabled: (value: boolean) => void;
a11YScreenreaderModeEnabled: () => boolean;
setA11YScreenreaderModeEnabled: (value: boolean) => void;
}

export const useAccessibility = (): Accessibility => {
Expand All @@ -47,9 +49,9 @@ export const useAccessibility = (): Accessibility => {
store.getters["accessibility/isHighContrastModeEnabled"],
setHighContrastModeEnabled: (enabled: boolean) =>
store.commit("accessibility/setHighContrastModeEnabled", enabled),
a11YNotificationEnabled: () =>
store.getters["accessibility/isA11YNotificationEnabled"],
setA11YNotificationEnabled: (enabled: boolean) =>
store.commit("accessibility/setA11YNotificationEnabled", enabled),
a11YScreenreaderModeEnabled: () =>
store.getters["accessibility/isA11YScreenreaderModeEnabled"],
setA11YScreenreaderModeEnabled: (enabled: boolean) =>
store.commit("accessibility/setA11YScreenreaderModeEnabled", enabled),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const safeValidation = ref(false);
const {showMessageAndLeavePage} = useNotificationContext();
const a11YNotificationEnabled = useAccessibility().a11YNotificationEnabled;
const a11YScreenreaderModeEnabled = useAccessibility().a11YScreenreaderModeEnabled;
/**
* toggle for showing fab menu
Expand Down Expand Up @@ -379,7 +379,7 @@ const handleCompleteTask = (model: any) => {
const handleSaveTask = (): Promise<void> => {
hasChanges.value = false;
if (!a11YNotificationEnabled()) {
if (!a11YScreenreaderModeEnabled()) {
safeValidation.value = true;
}
return saveTask(model.value)
Expand Down

0 comments on commit 7074941

Please sign in to comment.