Scroll wheel fix again

This commit is contained in:
2026-06-18 20:20:03 +01:00
parent 3f230bb0d7
commit 25c3f1fa64
2 changed files with 20 additions and 2 deletions
+19 -1
View File
@@ -502,6 +502,11 @@ function setupEventListeners() {
const dispenseQuantityInput = document.getElementById('dispenseQuantity'); const dispenseQuantityInput = document.getElementById('dispenseQuantity');
if (dispenseQuantityInput) { if (dispenseQuantityInput) {
// Prevent accidental value changes when users scroll while focused.
dispenseQuantityInput.addEventListener('wheel', (event) => {
event.preventDefault();
}, { passive: false });
dispenseQuantityInput.addEventListener('input', () => { dispenseQuantityInput.addEventListener('input', () => {
const mode = getSelectedDispenseMode(); const mode = getSelectedDispenseMode();
if (mode !== 'subunit') { if (mode !== 'subunit') {
@@ -524,6 +529,14 @@ function setupEventListeners() {
}); });
} }
const dispensePackCountInput = document.getElementById('dispensePackCount');
if (dispensePackCountInput) {
// Prevent accidental value changes when users scroll while focused.
dispensePackCountInput.addEventListener('wheel', (event) => {
event.preventDefault();
}, { passive: false });
}
// Close modal when clicking outside // Close modal when clicking outside
window.addEventListener('click', (e) => { window.addEventListener('click', (e) => {
if (e.target.classList.contains('modal')) { if (e.target.classList.contains('modal')) {
@@ -1279,7 +1292,7 @@ function renderDispenseBatchAllocationRows(activeBatches) {
: 0; : 0;
const allocationLabel = mode === 'pack' ? 'Allocate Packs' : 'Allocate'; const allocationLabel = mode === 'pack' ? 'Allocate Packs' : 'Allocate';
const allocationMax = mode === 'pack' ? availableFullPacks : getBatchAvailableDispenseQuantity(batch, mode, selectedPack); const allocationMax = mode === 'pack' ? availableFullPacks : getBatchAvailableDispenseQuantity(batch, mode, selectedPack);
const allocationStep = mode === 'pack' ? 1 : 0.1; const allocationStep = mode === 'pack' ? '1' : '1.0';
const batchAvailabilityNote = mode === 'pack' const batchAvailabilityNote = mode === 'pack'
? (selectedPack && batchMatchesSelectedPack(batch, selectedPack) && availableFullPacks <= 0 ? (selectedPack && batchMatchesSelectedPack(batch, selectedPack) && availableFullPacks <= 0
? 'No full packs available in this batch' ? 'No full packs available in this batch'
@@ -1324,6 +1337,11 @@ function renderDispenseBatchAllocationRows(activeBatches) {
}).join(''); }).join('');
batchInfoContent.querySelectorAll('.dispense-batch-allocation').forEach(input => { batchInfoContent.querySelectorAll('.dispense-batch-allocation').forEach(input => {
// Prevent accidental value changes when users scroll while focused.
input.addEventListener('wheel', (event) => {
event.preventDefault();
}, { passive: false });
input.addEventListener('input', updateDispenseAllocationSummary); input.addEventListener('input', updateDispenseAllocationSummary);
}); });
} }
+1 -1
View File
@@ -176,7 +176,7 @@
<div class="form-group" id="dispenseQuantityGroup"> <div class="form-group" id="dispenseQuantityGroup">
<label for="dispenseQuantity">Quantity *</label> <label for="dispenseQuantity">Quantity *</label>
<input type="number" id="dispenseQuantity" step="0.1"> <input type="number" id="dispenseQuantity" step="1.0">
</div> </div>
<div class="form-row" id="dispensePackRow" style="display: none;"> <div class="form-row" id="dispensePackRow" style="display: none;">