Closed Bug 1967915 Opened 2 months ago Closed 2 months ago

the onchange event is only fired every second time

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

Firefox 138
defect

Tracking

()

RESOLVED DUPLICATE of bug 53579

People

(Reporter: Paul.Heger, Unassigned)

Details

Attachments

(5 files, 1 obsolete file)

Attached image BWI-104.png

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:138.0) Gecko/20100101 Firefox/138.0

Steps to reproduce:

i have a table with input fields and when the user changes the first field value,
and goes to the next field (by tab or by click on the next field) the event is fired.
in the second field the user does the same, but the event is not fired.
third field ok again, forth bad again, and so on.
when the user goes back to field #2 and changes the value again, the event is fired.
In Edge the event is always fired.
All fields have the same function, only the parameters are different (this, col)
i tried both types:
//aInput.onchange = function(){ ChangedValue( aInput, col ); };
aInput.addEventListener("change", ChangedValue( aInput, col ) );
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:138.0) Gecko/20100101 Firefox/138.0

Actual results:

every second time the event is fired
every other time, the event is not fired

Expected results:

the function should have been called every time

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Events' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Events
Product: Firefox → Core

Thank you for the report!

I think we need some more information around what's failing. Is the following what you're describing:

<td><input type="text" onchange="..."></td>
<td><input type="text" onchange="..."></td>
<td><input type="text" onchange="..."></td>
<td><input type="text" onchange="..."></td>
Flags: needinfo?(Paul.Heger)

the addInput function creates theses inputs
inside a function addRow which i will add next

Flags: needinfo?(Paul.Heger)

this module displays a table for one person to store data for every day of a month.
there the user can add rows for selectable accounts and enter values.
After the value is entered, the onchange should check the sums are not exceeded for one day,
recalculate the values for the row and column sums.
But if the onchange is not fired, the checks are not done.
Can be seen on the picture i posted. red means, the values exceed the daily work done.
There is also no difference, whether the field is created by addInput, or by the java part of the jsp.

Thanks for sharing the code. It relies on external dependencies, so it's hard to reproduce locally. Could you provide a minimal reproducible example or a link to a deployed version?

Flags: needinfo?(Paul.Heger)

it seems to have something to do with the xtable framework
because when i recreated this simple file without xtable the error did not occur.

Flags: needinfo?(Paul.Heger)
Severity: -- → S3

Given that this works with Edge, it sounds like there's a web compat issue here. I don't know how widely used the xtable framework mentioned in comment 6 is.

Webcompat Priority: --- → ?
Attached file test_bug1967915.html (obsolete) —

The issue seems to be how alert and element.focus interact.


I attached a MRE.

STR

  • Select the first input element
  • Repeat: enter some text, press tab, dismiss any alerts

In Firefox, tab will move the focus to the next element. Though a focus indicator will remain on the second input, and there won't be a change event for it.

In Chromium, focus stays on the first element after tabbing.

I recorded a pernosco trace: https://pernos.co/debug/5DAcX5pcrxtmsWDQmeVkKQ/index.html

It seems, we don't get a blur event for the second input element. In Chromium, we actually get four events when tabbing: focus, blur, blur, focus. In Firefox, it's only blur, focus.

In general, a workaround could be to wrap setTimeout(() => i.focus(), 0). Though adding that to the ChangedValue method of the original code isn't enough.

Attached file test_bug1967915.html
Attachment #9493821 - Attachment is obsolete: true
Component: DOM: Events → DOM: UI Events & Focus Handling

Huh, this was just fixed by bug 53579.

Status: UNCONFIRMED → RESOLVED
Closed: 2 months ago
Duplicate of bug: 53579
Resolution: --- → DUPLICATE
Webcompat Priority: ? → ---
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: