Skip to content

Commit

Permalink
fix(text, shape): Hide generated text element from assitive technolog…
Browse files Browse the repository at this point in the history
…ies (#1551)
  • Loading branch information
thomashoggard authored Aug 3, 2022
1 parent c8dda52 commit a027ca6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/visx-shape/src/util/getOrCreateMeasurementElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export default function getOrCreateMeasurementElement(elementId: string) {
// create a single path element if not done already
if (!pathElement) {
const svg = document.createElementNS(SVG_NAMESPACE_URL, 'svg');

// not visible
svg.setAttribute('aria-hidden', 'true');
svg.style.opacity = '0';
svg.style.width = '0';
svg.style.height = '0';
Expand Down
1 change: 1 addition & 0 deletions packages/visx-text/src/util/getStringWidth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function getStringWidth(str: string, style?: object) {
let textEl = document.getElementById(MEASUREMENT_ELEMENT_ID) as SVGTextElement | null;
if (!textEl) {
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.setAttribute('aria-hidden', 'true');
svg.style.width = '0';
svg.style.height = '0';
svg.style.position = 'absolute';
Expand Down

0 comments on commit a027ca6

Please sign in to comment.