Skip to content

Strange focus jumping #193

Closed
Closed

Description

@itg-assistant

Alex Prinias asked 2016-07-31 18:18:26 UTC

Hi,

I saw this in my application and thought what have I done, how am I going to reproduce this and show it? It must be my binding or something...

I have two textboxes on a form

  • click with the mouse in one of them

  • type something into it

  • click with the mouse in the second textbox

  • the cursor goes back to the first textbox

  • if I click again in the second textbox, the focus stays there

Well, in a brand new window without any binding and just two textboxes, if i repeat the above steps, the cursor goes back to the first textbox for a split second and then goes to the second ...

I'll keep investigating.

Alex

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-08-01 12:36:14 UTC

    Hi Alex, I can't reproduce. Will keep trying. I have seen something similar in the past and it was caused by a mismatch between the focused control on the client and  the server.

  2. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Alex Prinias answered 2016-08-01 13:41:24 UTC

    Hi Luca,

    This won't be easy...

    Well, it has to do certainly (big word!) with the text change event. I can see it also when tabbing between the textboxes, not only when mouse-clicking.

    The reason I suspect the text change is that if I press a letter in the textbox and tab to the next textbox, the cursor comes back, and if I tab again, the focus moves to the next textbox. If however, after the first return to the first textbox, I type another letter and tab, the cursor returns to the first control, i.e., whenever there is a change, it returns, if there is no change it proceeds...

    I have removed my textbox validation events (which fired on text change) but the behaviour is the same. I have seen it a couple of times (but not always) disappear, if I do not run in debug mode. I also played with both values of the "optimizeFrames" flag, true and false, but didn't see a difference.

    Is there a way to check javascript events?

    Alex

  3. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-08-01 13:45:17 UTC

    You can enable console logging on the client using "debug":true. In VS you can see the traces from Wisej in view->output. I don't think it will help by looking at the logs. A lot of stuff happens simultaneously. But I think you are right, it's related to firing back the events. I will try that. I have an idea of what it may be.

  4. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-08-01 13:54:27 UTC

    Got it.

  5. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Alex Prinias answered 2016-08-01 14:22:52 UTC

    And ??

    :-)

  6. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-08-01 15:25:54 UTC

    It's the selection range. Wisej is also able to manage the selectedText, start, length in the text fields. But apparently some browsers change the focus, some don't, chrome was undecided, and it has been an issue for a while. So qooxdoo normalized it to always set the focus when setting the selected text. When wisej updates the controls on the client it may update the selection too and it will cause the focus to jump back.

  7. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Alex Prinias answered 2016-08-01 15:40:20 UTC

    Now if I say I understood, I'll be lying...

    The question is, can it be fixed? And why don't I see it on all forms? And why couldn't you reproduce it? Concerning browsers, it shows up in Chrome, IE, Edge, Firefox. In Opera the result is much worse, since the focus is completely lost and after a few tab clicks it focuses on a hidden control showing its border... Is it an effect of the latest build/latest qooxdoo?

    Alex

  8. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-08-01 15:43:14 UTC

    Because it depends on the sequence of events and if wisej has something to update on the textbox losing the focus. If the selection is set before the focus update then it's fine, or if there is not selection change it's also fine. To reproduce consistently I removed Wisej focus management in the test and let the browser handle it.

    Another issue can be that now Wisej executed the actions after yielding to the browser to let it update the screen.

    In any case, it's very easy to fix.

  9. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-08-01 15:48:01 UTC

    BTW, look at this to see why qooxdoo normalized it: https://codereview.chromium.org/392573002

  10. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Alex Prinias answered 2016-08-01 18:00:35 UTC

    Hi Luca,

    Can I have the fix to make sure this is the problem?

    Best,
    Alex

  11. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2016-08-01 18:28:42 UTC

    Sent it to you in a zip.

  12. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Alex Prinias answered 2016-08-01 20:31:49 UTC

    Confirmed fixed, Luca!

    Thank you very much.
    Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GeneralQuestions, how-tos and everything else.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions