From b1d49e9762525c0419ffab7e15ee7ea28ed2499d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kuna?= <1282324+codecalm@users.noreply.github.com> Date: Tue, 7 Jul 2026 23:46:05 +0200 Subject: [PATCH] Fix CountUp, dropdown viewport boundary, and input mask lazy option (#2684) --- .changeset/fix-countup-formatted-values.md | 5 +++++ .changeset/fix-dropdown-viewport-boundary.md | 5 +++++ .changeset/fix-input-mask-lazy-option.md | 5 +++++ core/js/src/countup.ts | 10 +++++++--- core/js/src/dropdown.ts | 2 +- core/js/src/input-mask.ts | 2 +- 6 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 .changeset/fix-countup-formatted-values.md create mode 100644 .changeset/fix-dropdown-viewport-boundary.md create mode 100644 .changeset/fix-input-mask-lazy-option.md diff --git a/.changeset/fix-countup-formatted-values.md b/.changeset/fix-countup-formatted-values.md new file mode 100644 index 000000000..99b793535 --- /dev/null +++ b/.changeset/fix-countup-formatted-values.md @@ -0,0 +1,5 @@ +--- +"@tabler/core": patch +--- + +Fixed CountUp to parse formatted number targets and avoid double-start when `enableScrollSpy` is enabled. diff --git a/.changeset/fix-dropdown-viewport-boundary.md b/.changeset/fix-dropdown-viewport-boundary.md new file mode 100644 index 000000000..dedc94fc6 --- /dev/null +++ b/.changeset/fix-dropdown-viewport-boundary.md @@ -0,0 +1,5 @@ +--- +"@tabler/core": patch +--- + +Fixed dropdown `data-bs-boundary="viewport"` to use `document.documentElement` instead of the first `.btn` element. diff --git a/.changeset/fix-input-mask-lazy-option.md b/.changeset/fix-input-mask-lazy-option.md new file mode 100644 index 000000000..6b771be29 --- /dev/null +++ b/.changeset/fix-input-mask-lazy-option.md @@ -0,0 +1,5 @@ +--- +"@tabler/core": patch +--- + +Fixed input mask `lazy` option to read `data-mask-visible` via `dataset.maskVisible`. diff --git a/core/js/src/countup.ts b/core/js/src/countup.ts index 300da6d2a..f13577ee2 100644 --- a/core/js/src/countup.ts +++ b/core/js/src/countup.ts @@ -15,11 +15,15 @@ if (countupElements.length) { // ignore invalid JSON } - const value = parseInt(element.innerHTML, 10) + // Strip thousands separators, currency symbols and other non-numeric characters + // so formatted targets like "1,234", "1 234" or "$99.5" parse correctly. + const value = parseFloat((element.textContent ?? '').replace(/[^0-9.-]/g, '')) - if (window.countUp && window.countUp.CountUp) { + if (!Number.isNaN(value) && window.countUp && window.countUp.CountUp) { const countUp = new window.countUp.CountUp(element, value, options) - if (!countUp.error) { + // When scrollSpy is enabled CountUp starts the animation itself once the + // element scrolls into view, so only start manually when it's disabled. + if (!countUp.error && !options.enableScrollSpy) { countUp.start() } } diff --git a/core/js/src/dropdown.ts b/core/js/src/dropdown.ts index dc53792fc..0607e72b4 100644 --- a/core/js/src/dropdown.ts +++ b/core/js/src/dropdown.ts @@ -6,7 +6,7 @@ Core dropdowns const dropdownTriggerList: HTMLElement[] = [].slice.call(document.querySelectorAll('[data-bs-toggle="dropdown"]')) dropdownTriggerList.map(function (dropdownTriggerEl: HTMLElement) { const options = { - boundary: dropdownTriggerEl.getAttribute('data-bs-boundary') === 'viewport' ? document.querySelector('.btn') : 'clippingParents', + boundary: dropdownTriggerEl.getAttribute('data-bs-boundary') === 'viewport' ? document.documentElement : 'clippingParents', } return new Dropdown(dropdownTriggerEl, options) }) diff --git a/core/js/src/input-mask.ts b/core/js/src/input-mask.ts index 0b5f53678..051911452 100644 --- a/core/js/src/input-mask.ts +++ b/core/js/src/input-mask.ts @@ -5,6 +5,6 @@ maskElementList.map(function (maskEl: HTMLElement) { window.IMask && new window.IMask(maskEl, { mask: maskEl.dataset.mask, - lazy: maskEl.dataset['mask-visible'] === 'true', + lazy: maskEl.dataset.maskVisible !== 'true', }) })