From f64a876ecaa098cbbc8f22711cf06ce09f537e3e Mon Sep 17 00:00:00 2001 From: TheSisb Date: Mon, 16 Oct 2023 16:13:23 -0500 Subject: [PATCH] fix: logspam and local test running --- .changeset/cold-brooms-type.md | 6 ++++++ jest.config.js | 1 + .../paste-core/components/meter/src/Meter.tsx | 15 ++++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 .changeset/cold-brooms-type.md diff --git a/.changeset/cold-brooms-type.md b/.changeset/cold-brooms-type.md new file mode 100644 index 0000000000..e46ef58abf --- /dev/null +++ b/.changeset/cold-brooms-type.md @@ -0,0 +1,6 @@ +--- +"@twilio-paste/meter": patch +"@twilio-paste/core": patch +--- + +[Meter] Remove console.warn log spam regarding aria-label diff --git a/jest.config.js b/jest.config.js index e07b997a9d..ad3e4aa191 100644 --- a/jest.config.js +++ b/jest.config.js @@ -14,6 +14,7 @@ module.exports = { "/packages/(?:.+?)/.next/", "/templates/(?:.+?)/.next/", "/packages/(?:.+?)/.netlify/", + "/.netlify/", ], cacheDirectory: ".jest-cache", coverageDirectory: ".jest-coverage", diff --git a/packages/paste-core/components/meter/src/Meter.tsx b/packages/paste-core/components/meter/src/Meter.tsx index 26af10cac2..1b550a16b5 100644 --- a/packages/paste-core/components/meter/src/Meter.tsx +++ b/packages/paste-core/components/meter/src/Meter.tsx @@ -21,11 +21,6 @@ export interface MeterProps extends HTMLPasteProps<"meter">, Pick( ({ element = "METER", id, minLabel, maxLabel, ...props }, ref) => { const { value = 0, minValue = 0, maxValue = 100 } = props; - const { meterProps } = useMeter(props); - - // Calculate the width of the bar as a percentage - const percentage = (value - minValue) / (maxValue - minValue); - const fillWidth = `${Math.round(percentage * 100)}%`; /* * Since Meter isn't a form element, we cannot use htmlFor from the regular Label @@ -38,6 +33,16 @@ const Meter = React.forwardRef( labelledBy = `${id}${LABEL_SUFFIX}`; } + const { meterProps } = useMeter({ + ...props, + // Appeases useLabel's internal warning about missing labels because we're doing our own thing + "aria-labelledby": labelledBy, + }); + + // Calculate the width of the bar as a percentage + const percentage = (value - minValue) / (maxValue - minValue); + const fillWidth = `${Math.round(percentage * 100)}%`; + return (