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

Allow passing array to aria and ariaLabelledby for labeling multiple handles #89

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Write some comments
oliver139 committed May 29, 2024
commit 7943fac40dd5296a0ac5bb4abfd17cee4b4a5af7
10 changes: 9 additions & 1 deletion src/composables/useSlider.js
Original file line number Diff line number Diff line change
@@ -56,24 +56,32 @@ export default function useSlider (props, context, dependencies)
defaultOptions.connect = true
}

// if ((ariaLabelledby && ariaLabelledby.value) || (aria && Object.keys(aria.value).length)) {
// Check if aria / ariaLabelledby is provided
if ((ariaLabelledby && ariaLabelledby.value) || (aria && aria.value)) {
const handles = Array.isArray(value.value) ? value.value : [value.value];

// For each handle
defaultOptions.handleAttributes = handles.map((h, i) => {
const output = {};

// if aria provided
if (aria.value) {
if (Array.isArray(aria.value)) {
// If array is provided, assign the value respectively
Object.assign(output, aria.value[i]);
} else {
// Else assign the object
Object.assign(output, aria.value);
}
}

// if ariaLabelledby provided
if (ariaLabelledby.value) {
if (typeof ariaLabelledby.value === 'string') {
// if string is provided, assign the value in object format
Object.assign(output, { 'aria-labelledby': ariaLabelledby.value });
} else {
// Else if string array is provided, assign the value respectively
Object.assign(output, { 'aria-labelledby': ariaLabelledby.value[i] });
}
}