Skip to content

Commit

Permalink
#2328 SVG Elements Lack Accessible Names in Common Canvas Nodes (#2330)
Browse files Browse the repository at this point in the history
Signed-off-by: srikant <[email protected]>
  • Loading branch information
srikant-ch5 authored Jan 30, 2025
1 parent e7d9c61 commit 8cf373d
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2859,7 +2859,9 @@ export default class SVGCanvasRenderer {
} else {
imageSel.selectChild("svg").remove();
d3.svg(image, { cache: "force-cache" }).then((data) => {
imageSel.node().append(data.documentElement);
const svgElement = data.documentElement;
svgElement.setAttribute("aria-label", "Node Image");
imageSel.node().append(svgElement);
});
}
} else {
Expand Down Expand Up @@ -2938,22 +2940,26 @@ export default class SVGCanvasRenderer {
getImageElement(node) {
const nodeImage = this.getNodeImage(node);
const imageType = this.getImageType(nodeImage);
const nodeAriaLabel = node?.label;

if (imageType === "jsx") {
return d3.create("svg:foreignObject")
.attr("tabindex", -1)
.attr("class", "d3-foreign-object-node-image d3-node-image")
.attr("aria-label", nodeAriaLabel)
.node();

} else if (imageType === "svg") {
return d3.create("svg")
.attr("class", "d3-node-image")
.attr("aria-label", nodeAriaLabel)
.node();

}
// If imageType is "image" or null, we create an image element
return d3.create("svg:image")
.attr("class", "d3-node-image")
.attr("aria-label", nodeAriaLabel)
.node();
}

Expand Down

0 comments on commit 8cf373d

Please sign in to comment.