Skip to content

Commit e4c5447

Browse files
committed
input-num disabled fix
inner focusable element(s) must set tabindex to -1 too. doesn't inherit from host like pointer-events.
1 parent b642303 commit e4c5447

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

input-num.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ static observedAttributes = [
166166
// valid value. Validation of string values is left to the DOM.
167167
attributeChangedCallback(name, _, val) {
168168
let isResize, isUpdate;
169+
const isNull = (val === null);
170+
169171
if (name in this.#attrs) { // numeric attributes
170172
const n = this.#toNumber(val);
171173
if (Number.isNaN(n) && name != STEP) {
@@ -174,7 +176,7 @@ static observedAttributes = [
174176
} //-----------
175177
switch (name) {
176178
case STEP:
177-
if (val === null)
179+
if (isNull)
178180
this.#attrs[STEP] = this.#autoStep(this.#attrs[DIGITS]);
179181
else if (n)
180182
this.#accept(name, n);
@@ -221,15 +223,15 @@ static observedAttributes = [
221223
case NO_KEYS:
222224
isResize = false;
223225
if (this.#input) // for noAwait
224-
this.#input.disabled = (val !== null);
226+
this.#input.disabled = !isNull;
225227
break;
226228
case NO_CONFIRM:
227229
case NO_SPIN: // assume element does not have focus
228230
this.#swapEvents(true);
229231
break;
230232
case NO_ALIGN:
231233
if (this.#input) { // for noAwait
232-
const args = (val === null) ? textAlign : [textAlign[0], null];
234+
const args = isNull ? textAlign : [textAlign[0], null];
233235
this.#input.style.setProperty(...args);
234236
}
235237
case NO_WIDTH:
@@ -239,15 +241,15 @@ static observedAttributes = [
239241
isUpdate = true;
240242
switch(name) {
241243
case LOCALE: // the decimal marker:
242-
this.#decimal = (val === null)
244+
this.#decimal = isNull
243245
? "." // convert "" to undefined
244246
: Intl.NumberFormat(val || undefined)
245247
.formatToParts(.1)
246248
.find(p => p.type == "decimal")
247249
.value;
248250
break;
249251
case ACCOUNTING:
250-
this.#locale.currencySign = (val !== null)
252+
this.#locale.currencySign = !isNull
251253
? "accounting" : undefined;
252254
case UNITS: // strings:
253255
break;
@@ -257,8 +259,9 @@ static observedAttributes = [
257259
this.#locale[name] = val ?? undefined;
258260
break;
259261
case DISABLED: // falls through
262+
this.#input.tabIndex = isNull ? 0 : -1;
260263
for (const elm of this.#btns)
261-
elm.style.pointerEvents = (val === null) ? "" : "none";
264+
elm.style.pointerEvents = isNull ? "" : "none";
262265
default: // handled by BaseElement
263266
super.attributeChangedCallback(name, _, val);
264267
return;

0 commit comments

Comments
 (0)