Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Problem with setFocus on a TextField on an Modal Window in IE8/IE9
I am experiencing a little problem and am curious if I am the only one or if someone else has already solved it.
I have a normal frame with a text field on it (with the focus) and want to open a modal window again with a textfield on it. Then I want to transfer the focus from the frame-textfield to the modal window-textfield. In chrome and firefox this is working no problem, but with ie8 and ie9 it doesn't work. Instead, the focus remains on the frame and cannot be moved by typing keys or using tab. Only with the mouse can the focus be transfered to the modal window.
The debug-view shows me that the json requests the focus for the correct element. And setFocus() is called on the correct element. Like I said, in chrome and firefox this works.
I have tried to set a timer to delay the call of setFocus() to give the browser time to completely render all elements, that did not solve the problem.
What did solve the problem for me was to call setFocus() on the textfield twice. Yes, it's like: "textfield, take the focus" - "no, i don't want to" - "don't make me come over" - "okay, fine..".
Has someone has an explanation for this? Or a better solution?
Awesome description of discussion between your code and the textfield. :D
Sounds like a bug to me. I'd suggest that you make a stand alone application of around ten lines of code that demonstrates this problem, and file a bug ticket with it at dev.vaadin.com. Make a search at the site before you do it, to check if there is already a ticket about it.