Open OlliTietavainenVaadin opened 4 years ago
Most affected components are probably using a synchronized element property for propagating the value back to the server. We could in theory force a sync of such properties (regardless of debounce or throttle settings) before the key event is sent to the server.
Some open questions for that approach:
activeElement
instances so that a sync would be triggered for e.g. <vaadin-text-field>
even though that element is inside a shadow root and the actually focused element is the <input>
inside the text field's shadow root.DomListenerRegistration
.There may also be components that sync their value e.g. as event details for a DOM event or through @ClientCallable
. Such cases would most likely require some coordination with the component's connector logic. One potential approach would be that the connector can register a client-side listener that is run when this kind of synchronization should be triggered and then do its magic in that one.
It can be simply reproduced with the following piece of code.
TextField textField = new TextField();
add(textField);
Button button = new Button("Click", event -> System.out.println(textField.getValue()));
button.addClickShortcut(Key.KEY_S, KeyModifier.CONTROL);
add(button);
When the text field is focused, pressing Ctrl+S doesn't print its current value.
Cross-posting: same issue with a workaround https://github.com/vaadin/flow/issues/17484.
Vaadin 14.0
In some components, the value of the component might not get updated when a shortcut listener is triggered. For example, there could be a shortcut
Ctrl+S
for saving a form. If you have a TextField focused with some text entered and the shortcut is pressed, the TextField's new value is not available on the server, while this would be the expected behavior in many cases.