From 1d28b8c2b3af0ac2d91c72fc2965578316a2c0b3 Mon Sep 17 00:00:00 2001 From: CPTN Cosmo Date: Fri, 19 Dec 2025 02:09:23 +0100 Subject: [PATCH] refactor: Use native DOM events for resetting input values instead of jQuery triggers. --- scripts/module.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/module.js b/scripts/module.js index d1986ec..25d2315 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -200,17 +200,23 @@ Hooks.on('renderSettingsConfig', (app, html, data) => { const resetBtn = $(``); resetBtn.on('click', () => { - // 1. Update Number Input (if exists) - this is usually the one with the name attribute + // Use Native DOM events for maximum compatibility with Foundry + // 1. Update Number Input (if exists) if (numberInput.length) { - numberInput.val(1.0).trigger('change'); + const nativeNum = numberInput[0]; + nativeNum.value = 1.0; + nativeNum.dispatchEvent(new Event('change', { bubbles: true })); } - // 2. Update Range Input - this triggers the visual slider movement + // 2. Update Range Input if (input.length) { - input.val(1.0).trigger('input').trigger('change'); + const nativeRange = input[0]; + nativeRange.value = 1.0; + nativeRange.dispatchEvent(new Event('input', { bubbles: true })); + nativeRange.dispatchEvent(new Event('change', { bubbles: true })); } - // 3. Manually update the text display just in case + // 3. Fallback visual update if (rangeValue.length) rangeValue.text("1.0"); });