mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
A11Y: makes aria-owns an ID and not a data attribute (#12075)
This commit is contained in:
@@ -776,10 +776,10 @@ export default Component.extend(
|
|||||||
|
|
||||||
if (!this.popper) {
|
if (!this.popper) {
|
||||||
const anchor = document.querySelector(
|
const anchor = document.querySelector(
|
||||||
`[data-select-kit-id=${this.selectKit.uniqueID}-header]`
|
`#${this.selectKit.uniqueID}-header`
|
||||||
);
|
);
|
||||||
const popper = document.querySelector(
|
const popper = document.querySelector(
|
||||||
`[data-select-kit-id=${this.selectKit.uniqueID}-body]`
|
`#${this.selectKit.uniqueID}-body`
|
||||||
);
|
);
|
||||||
|
|
||||||
const inModal = $(this.element).parents("#discourse-modal").length;
|
const inModal = $(this.element).parents("#discourse-modal").length;
|
||||||
@@ -954,15 +954,11 @@ export default Component.extend(
|
|||||||
},
|
},
|
||||||
|
|
||||||
getFilterInput() {
|
getFilterInput() {
|
||||||
return document.querySelector(
|
return document.querySelector(`#${this.selectKit.uniqueID}-filter input`);
|
||||||
`[data-select-kit-id=${this.selectKit.uniqueID}-filter] input`
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getHeader() {
|
getHeader() {
|
||||||
return document.querySelector(
|
return document.querySelector(`#${this.selectKit.uniqueID}-header`);
|
||||||
`[data-select-kit-id=${this.selectKit.uniqueID}-header]`
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleDeprecations() {
|
handleDeprecations() {
|
||||||
|
|||||||
@@ -6,11 +6,8 @@ import layout from "select-kit/templates/components/select-kit/select-kit-body";
|
|||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layout,
|
layout,
|
||||||
classNames: ["select-kit-body"],
|
classNames: ["select-kit-body"],
|
||||||
attributeBindings: ["role", "selectKitId:data-select-kit-id"],
|
attributeBindings: ["role"],
|
||||||
classNameBindings: ["emptyBody:empty-body"],
|
classNameBindings: ["emptyBody:empty-body"],
|
||||||
selectKitId: computed("selectKit.uniqueID", function () {
|
|
||||||
return `${this.selectKit.uniqueID}-body`;
|
|
||||||
}),
|
|
||||||
emptyBody: computed("selectKit.{filter,hasNoContent}", function () {
|
emptyBody: computed("selectKit.{filter,hasNoContent}", function () {
|
||||||
return !this.selectKit.filter && this.selectKit.hasNoContent;
|
return !this.selectKit.filter && this.selectKit.hasNoContent;
|
||||||
}),
|
}),
|
||||||
@@ -50,7 +47,7 @@ export default Component.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const headerElement = document.querySelector(
|
const headerElement = document.querySelector(
|
||||||
`[data-select-kit-id=${this.selectKit.uniqueID}-header]`
|
`#${this.selectKit.uniqueID}-header`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (headerElement && headerElement.contains(event.target)) {
|
if (headerElement && headerElement.contains(event.target)) {
|
||||||
|
|||||||
@@ -11,10 +11,7 @@ export default Component.extend(UtilsMixin, {
|
|||||||
layout,
|
layout,
|
||||||
classNames: ["select-kit-filter"],
|
classNames: ["select-kit-filter"],
|
||||||
classNameBindings: ["isExpanded:is-expanded"],
|
classNameBindings: ["isExpanded:is-expanded"],
|
||||||
attributeBindings: ["role", "selectKitId:data-select-kit-id"],
|
attributeBindings: ["role"],
|
||||||
selectKitId: computed("selectKit.uniqueID", function () {
|
|
||||||
return `${this.selectKit.uniqueID}-filter`;
|
|
||||||
}),
|
|
||||||
|
|
||||||
role: "searchbox",
|
role: "searchbox",
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ export default Component.extend(UtilsMixin, {
|
|||||||
"ariaOwns:aria-owns",
|
"ariaOwns:aria-owns",
|
||||||
"ariaHasPopup:aria-haspopup",
|
"ariaHasPopup:aria-haspopup",
|
||||||
"ariaIsExpanded:aria-expanded",
|
"ariaIsExpanded:aria-expanded",
|
||||||
"selectKitId:data-select-kit-id",
|
|
||||||
"roleButton:role",
|
"roleButton:role",
|
||||||
"selectedValue:data-value",
|
"selectedValue:data-value",
|
||||||
"selectedNames:data-name",
|
"selectedNames:data-name",
|
||||||
@@ -63,10 +62,6 @@ export default Component.extend(UtilsMixin, {
|
|||||||
return icon.concat(icons).filter(Boolean);
|
return icon.concat(icons).filter(Boolean);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
selectKitId: computed("selectKit.uniqueID", function () {
|
|
||||||
return `${this.selectKit.uniqueID}-header`;
|
|
||||||
}),
|
|
||||||
|
|
||||||
ariaIsExpanded: computed("selectKit.isExpanded", function () {
|
ariaIsExpanded: computed("selectKit.isExpanded", function () {
|
||||||
return this.selectKit.isExpanded ? "true" : "false";
|
return this.selectKit.isExpanded ? "true" : "false";
|
||||||
}),
|
}),
|
||||||
@@ -74,7 +69,7 @@ export default Component.extend(UtilsMixin, {
|
|||||||
ariaHasPopup: "menu",
|
ariaHasPopup: "menu",
|
||||||
|
|
||||||
ariaOwns: computed("selectKit.uniqueID", function () {
|
ariaOwns: computed("selectKit.uniqueID", function () {
|
||||||
return `[data-select-kit-id=${this.selectKit.uniqueID}-body]`;
|
return `${this.selectKit.uniqueID}-body`;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
roleButton: "button",
|
roleButton: "button",
|
||||||
@@ -178,7 +173,7 @@ export default Component.extend(UtilsMixin, {
|
|||||||
|
|
||||||
_focusFilterInput() {
|
_focusFilterInput() {
|
||||||
const filterContainer = document.querySelector(
|
const filterContainer = document.querySelector(
|
||||||
`[data-select-kit-id=${this.selectKit.uniqueID}-filter]`
|
`#${this.selectKit.uniqueID}-filter`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (filterContainer) {
|
if (filterContainer) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
<div class="choice input-wrapper">
|
<div class="choice input-wrapper">
|
||||||
{{component selectKit.options.filterComponent
|
{{component selectKit.options.filterComponent
|
||||||
selectKit=selectKit
|
selectKit=selectKit
|
||||||
|
id=(concat selectKit.uniqueID "-filter")
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|||||||
@@ -4,9 +4,10 @@
|
|||||||
value=value
|
value=value
|
||||||
selectedContent=selectedContent
|
selectedContent=selectedContent
|
||||||
selectKit=selectKit
|
selectKit=selectKit
|
||||||
|
id=(concat selectKit.uniqueID "-header")
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{#select-kit/select-kit-body selectKit=selectKit}}
|
{{#select-kit/select-kit-body selectKit=selectKit id=(concat selectKit.uniqueID "-body")}}
|
||||||
{{#if selectKit.isLoading}}
|
{{#if selectKit.isLoading}}
|
||||||
<span class="is-loading">
|
<span class="is-loading">
|
||||||
{{loading-spinner size="small"}}
|
{{loading-spinner size="small"}}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<div class="choice input-wrapper">
|
<div class="choice input-wrapper">
|
||||||
{{component selectKit.options.filterComponent
|
{{component selectKit.options.filterComponent
|
||||||
selectKit=selectKit
|
selectKit=selectKit
|
||||||
|
id=(concat selectKit.uniqueID "-filter")
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
value=value
|
value=value
|
||||||
selectedContent=selectedContent
|
selectedContent=selectedContent
|
||||||
selectKit=selectKit
|
selectKit=selectKit
|
||||||
|
id=(concat selectKit.uniqueID "-header")
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{#select-kit/select-kit-body selectKit=selectKit}}
|
{{#select-kit/select-kit-body selectKit=selectKit id=(concat selectKit.uniqueID "-body")}}
|
||||||
{{component selectKit.options.filterComponent selectKit=selectKit}}
|
{{component selectKit.options.filterComponent selectKit=selectKit id=(concat selectKit.uniqueID "-filter")}}
|
||||||
|
|
||||||
{{#if selectKit.isLoading}}
|
{{#if selectKit.isLoading}}
|
||||||
<span class="is-loading">
|
<span class="is-loading">
|
||||||
|
|||||||
Reference in New Issue
Block a user