Skip to content

FOUR-22582: [SUMMER 25] UI Improvements Summer 2025 - Accesibility #449

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
103 changes: 32 additions & 71 deletions src/components/FormSelectList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<required-asterisk /><label v-uni-for="name">{{ label }}</label>
<multi-select-view
v-if="options.renderAs === 'dropdown'"
v-model="valueProxy"
v-uni-id="name"
:option-value="optionsKey"
:option-content="optionsValue"
:option-aria-label="optionsAriaLabel"
v-uni-id="name"
v-model="valueProxy"
:placeholder="placeholder ? placeholder : $t('Select...')"
:show-labels="false"
:options="selectListOptionsWithSelected"
Expand All @@ -16,8 +16,8 @@
:emit-objects="options.valueTypeReturned === 'object'"
:emit-array="options.allowMultiSelect"
v-bind="$attrs"
@search-change="searchChange"
:loading="loading"
@search-change="searchChange"
>
</multi-select-view>

Expand Down Expand Up @@ -51,10 +51,7 @@
/>
</div>

<div
v-if="(validator && validator.errorCount) || error"
class="invalid-feedback d-block"
>
<div v-if="(validator && validator.errorCount) || error" class="invalid-feedback d-block">
<div v-for="(error, index) in validatorErrors" :key="index">
{{ error }}
</div>
Expand All @@ -70,9 +67,9 @@ import Mustache from "mustache";
import { isEqual, cloneDeep, get, set, debounce } from "lodash";
import ValidationMixin from "./mixins/validation";
import MultiSelectView from "./FormSelectList/MultiSelectView";
import CheckboxView from "./FormSelectList/CheckboxView";
import OptionboxView from "./FormSelectList/OptionboxView";
import RequiredAsterisk from './common/RequiredAsterisk';
import CheckboxView from "./FormSelectList/CheckboxView";
import RequiredAsterisk from "./common/RequiredAsterisk";

const uniqIdsMixin = createUniqIdsMixin();

Expand All @@ -81,8 +78,8 @@ const MAX_COLLECTION_RECORDS = 100;
export default {
components: {
OptionboxView,
MultiSelectView,
CheckboxView,
MultiSelectView,
RequiredAsterisk
},
mixins: [uniqIdsMixin, ValidationMixin],
Expand Down Expand Up @@ -112,24 +109,24 @@ export default {
loaded: false,
previousDependentValue: null,
filter: "",
countWithoutFilter: null,
countWithoutFilter: null
};
},
computed: {
selectListOptionsWithSelected() {
if (this.selectedOption && !this.selectListOptions.some(o => o.value === this.selectedOption.value)) {
if (this.selectedOption && !this.selectListOptions.some((o) => o.value === this.selectedOption.value)) {
return [this.selectedOption, ...this.selectListOptions];
}
return this.selectListOptions;
},
collectionOptions() {
return get(this.options, 'collectionOptions');
return get(this.options, "collectionOptions");
},
isDataConnector() {
return get(this.options, 'dataSource') === "dataConnector";
return get(this.options, "dataSource") === "dataConnector";
},
isCollection() {
return get(this.options, 'dataSource') === "collection";
return get(this.options, "dataSource") === "collection";
},
mode() {
return this.$root.$children[0].mode;
Expand Down Expand Up @@ -186,23 +183,16 @@ export default {
return this.value;
},
set(val) {
this.selectedOption = val ? this.selectListOptions.find(o => o.value === val) : null;
this.selectedOption = val ? this.selectListOptions.find((o) => o.value === val) : null;
return this.$emit("input", val);
}
},
optionsKey() {
if (
this.options.dataSource &&
this.options.dataSource === "provideData"
) {
if (this.options.dataSource && this.options.dataSource === "provideData") {
return "value";
}

if (
this.options.dataSource &&
this.options.dataSource === "dataConnector" &&
this.options.valueTypeReturned === "object"
) {
if (this.options.dataSource && this.options.dataSource === "dataConnector" && this.options.valueTypeReturned === "object") {
return this.optionsValue;
}

Expand All @@ -211,29 +201,20 @@ export default {
return this.stripMustache(fieldName);
},
optionsValue() {
if (
this.options.dataSource &&
(this.options.dataSource === "provideData" ||
this.isCollection)
) {
if (this.options.dataSource && (this.options.dataSource === "provideData" || this.isCollection)) {
return "content";
}
return "__content__";
},
optionsAriaLabel() {
if (
this.options.dataSource &&
(this.options.dataSource === "provideData" ||
this.isCollection)
) {
if (this.options.dataSource && (this.options.dataSource === "provideData" || this.isCollection)) {
return "ariaLabel";
}
return "__ariaLabel__";
},
classList() {
return {
"has-errors":
(this.validator && this.validator.errorCount) || this.error,
"has-errors": (this.validator && this.validator.errorCount) || this.error,
[this.controlClass]: !!this.controlClass
};
}
Expand All @@ -242,7 +223,7 @@ export default {
selectListOptions: {
handler() {
if (this.isCollection) {
if (this.value && !this.selectListOptions.some(o => o.value === this.value)) {
if (this.value && !this.selectListOptions.some((o) => o.value === this.value)) {
this.loadIndividualRecord();
}
}
Expand Down Expand Up @@ -442,10 +423,7 @@ export default {
}

this.loading = true;
const [data] = await this.$dataProvider.getCollectionRecords(
this.collectionOptions.collectionId,
{ params: { pmql } }
);
const [data] = await this.$dataProvider.getCollectionRecords(this.collectionOptions.collectionId, { params: { pmql } });
this.loading = false;

if (data.data && data.data.length > 0) {
Expand All @@ -456,18 +434,14 @@ export default {
}
},
async getCollectionRecords(options) {
let data = { data : [] };
let data = { data: [] };
let resolvedNonce = null;

// Nonce ensures we only use results from the latest request
this.nonce = Math.random();

this.loading = true;
[data, resolvedNonce] = await this.$dataProvider.getCollectionRecords(
this.collectionOptions.collectionId,
options,
this.nonce
);
[data, resolvedNonce] = await this.$dataProvider.getCollectionRecords(this.collectionOptions.collectionId, options, this.nonce);
this.loading = false;

if (resolvedNonce !== this.nonce) {
Expand All @@ -482,7 +456,7 @@ export default {

this.selectListOptions = data.data.map(this.formatCollectionRecordResults);
},
debouncedSetFilter: debounce(function(value) {
debouncedSetFilter: debounce(function (value) {
this.filter = value;
}, 300),
searchChange(value) {
Expand All @@ -502,15 +476,8 @@ export default {
*/
async fillSelectListOptions(resetValueIfNotInOptions) {
let wasUpdated = false;
if (
this.options.dataSource &&
this.options.dataSource === "provideData"
) {
if (
this.options &&
this.options.optionsList &&
!isEqual(this.selectListOptions, this.options.optionsList)
) {
if (this.options.dataSource && this.options.dataSource === "provideData") {
if (this.options && this.options.optionsList && !isEqual(this.selectListOptions, this.options.optionsList)) {
this.selectListOptions = this.options.optionsList;
}
this.selectListOptions = this.selectListOptions || [];
Expand All @@ -531,10 +498,7 @@ export default {
wasUpdated = true;
}

if (
this.options.dataSource &&
this.options.dataSource === "dataConnector"
) {
if (this.options.dataSource && this.options.dataSource === "dataConnector") {
wasUpdated = await this.loadOptionsFromDataConnector(this.sourceConfig);
}

Expand All @@ -558,7 +522,7 @@ export default {
const resultList = [];

if (!Array.isArray(list)) {
console.warn('The retrieved data is not an array. Please check the data sources options of the select list `' + this.name + '`')
console.warn(`The retrieved data is not an array. Please check the data sources options of the select list \`${this.name}\``);
return resultList;
}

Expand All @@ -583,9 +547,10 @@ export default {
// Modified ariaLabel handling
let itemAriaLabel = itemContent;
if (this.options.optionAriaLabel) {
itemAriaLabel = this.options.optionAriaLabel.indexOf("{{") >= 0
? Mustache.render(this.options.optionAriaLabel, item)
: Mustache.render(`{{${this.options.optionAriaLabel || "ariaLabel"}}}`, item);
itemAriaLabel =
this.options.optionAriaLabel.indexOf("{{") >= 0
? Mustache.render(this.options.optionAriaLabel, item)
: Mustache.render(`{{${this.options.optionAriaLabel || "ariaLabel"}}}`, item);
}

Mustache.escape = escape; // Reset mustache to original escape function
Expand Down Expand Up @@ -662,11 +627,7 @@ export default {
return parsedOption;
},
stripMustache(str) {
const removed = str
.replace(/{{/g, "")
.replace(/}}/g, "")
.split(".")
.pop();
const removed = str.replace(/{{/g, "").replace(/}}/g, "").split(".").pop();

return removed || str;
},
Expand Down
Loading
Loading