diff options
author | Artur Signell <artur@vaadin.com> | 2013-03-21 08:59:51 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-03-21 08:59:51 +0200 |
commit | bd3bb24a36a0ad02ffb9cee2e46afc445a354191 (patch) | |
tree | 00d9248c84f8b7b60768552c822279c9cf151f45 /client | |
parent | 320b4e3776976e5dad822f01542f338cf76140bb (diff) | |
parent | e4c9eda51082a443822b66864df2fe14be7dc6d7 (diff) | |
download | vaadin-framework-bd3bb24a36a0ad02ffb9cee2e46afc445a354191.tar.gz vaadin-framework-bd3bb24a36a0ad02ffb9cee2e46afc445a354191.zip |
Merge commit 'e4c9eda51082a443822b66864df2fe14be7dc6d7'
Conflicts:
uitest/test.xml
Change-Id: I2c82fa7117b21bddad313abdd2f3f43143317c12
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ApplicationConnection.java | 1 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/AbstractComponentConnector.java | 17 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/FocusUtil.java | 94 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/MediaBaseConnector.java | 25 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VMediaBase.java | 26 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VScrollTable.java | 24 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VTextArea.java | 122 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VTextField.java | 4 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VTree.java | 2 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VUI.java | 25 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/VWindow.java | 34 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/audio/AudioConnector.java | 48 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java | 4 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/ui/UIConnector.java | 8 |
14 files changed, 389 insertions, 45 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index 62827feffb..4ddbd7c39b 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -510,6 +510,7 @@ public class ApplicationConnection { client.getPathForElement = $entry(function(element) { return componentLocator.@com.vaadin.client.ComponentLocator::getPathForElement(Lcom/google/gwt/user/client/Element;)(element); }); + client.initializing = false; $wnd.vaadin.clients[TTAppId] = client; }-*/; diff --git a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java index 694db6f02c..ecd6abae08 100644 --- a/client/src/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/com/vaadin/client/ui/AbstractComponentConnector.java @@ -137,10 +137,19 @@ public abstract class AbstractComponentConnector extends AbstractConnector * implementation). */ Profiler.enter("AbstractComponentConnector.onStateChanged update tab index"); - if (getState() instanceof TabIndexState - && getWidget() instanceof Focusable) { - ((Focusable) getWidget()) - .setTabIndex(((TabIndexState) getState()).tabIndex); + if (getState() instanceof TabIndexState) { + if (getWidget() instanceof Focusable) { + ((Focusable) getWidget()) + .setTabIndex(((TabIndexState) getState()).tabIndex); + } else { + /* + * TODO Enable this error when all widgets have been fixed to + * properly support tabIndex, i.e. implement Focusable + */ + // VConsole.error("Tab index received for " + // + Util.getSimpleName(getWidget()) + // + " which does not implement Focusable"); + } } Profiler.leave("AbstractComponentConnector.onStateChanged update tab index"); diff --git a/client/src/com/vaadin/client/ui/FocusUtil.java b/client/src/com/vaadin/client/ui/FocusUtil.java new file mode 100644 index 0000000000..8de3f767bd --- /dev/null +++ b/client/src/com/vaadin/client/ui/FocusUtil.java @@ -0,0 +1,94 @@ +/* + * Copyright 2000-2013 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.ui; + +import com.google.gwt.user.client.ui.Focusable; +import com.google.gwt.user.client.ui.Widget; + +/** + * A helper class used to make it easier for {@link Widget}s to implement + * {@link Focusable}. + * + * @author Vaadin Ltd + * @version @VERSION@ + * @since 7.0.3 + * + */ +public class FocusUtil { + + /** + * Sets the access key property + * + * @param focusable + * The widget for which we want to set the access key. + * @param key + * The access key to set + */ + public static void setAccessKey(Widget focusable, char key) { + assert (focusable != null && focusable.getElement() != null) : "Can't setAccessKey for a widget without an element"; + focusable.getElement().setPropertyString("accessKey", "" + key); + } + + /** + * Explicitly focus/unfocus the given widget. Only one widget can have focus + * at a time, and the widget that does will receive all keyboard events. + * + * @param focusable + * the widget to focus/unfocus + * @param focused + * whether this widget should take focus or release it + */ + public static void setFocus(Widget focusable, boolean focus) { + assert (focusable != null && focusable.getElement() != null) : "Can't setFocus for a widget without an element"; + + if (focus) { + focusable.getElement().focus(); + } else { + focusable.getElement().blur(); + } + } + + /** + * Sets the widget's position in the tab index. If more than one widget has + * the same tab index, each such widget will receive focus in an arbitrary + * order. Setting the tab index to <code>-1</code> will cause the widget to + * be removed from the tab order. + * + * @param focusable + * The widget + * @param tabIndex + * the widget's tab index + */ + public static void setTabIndex(Widget focusable, int tabIndex) { + assert (focusable != null && focusable.getElement() != null) : "Can't setTabIndex for a widget without an element"; + + focusable.getElement().setTabIndex(tabIndex); + } + + /** + * Gets the widget's position in the tab index. + * + * @param focusable + * The widget + * + * @return the widget's tab index + */ + public static int getTabIndex(Widget focusable) { + assert (focusable != null && focusable.getElement() != null) : "Can't getTabIndex for a widget without an element"; + + return focusable.getElement().getTabIndex(); + } +} diff --git a/client/src/com/vaadin/client/ui/MediaBaseConnector.java b/client/src/com/vaadin/client/ui/MediaBaseConnector.java index 6824caff78..8614977be1 100644 --- a/client/src/com/vaadin/client/ui/MediaBaseConnector.java +++ b/client/src/com/vaadin/client/ui/MediaBaseConnector.java @@ -46,15 +46,26 @@ public abstract class MediaBaseConnector extends AbstractComponentConnector { } @Override - public void onStateChanged(StateChangeEvent stateChangeEvent) { - super.onStateChanged(stateChangeEvent); + public void onStateChanged(StateChangeEvent event) { + super.onStateChanged(event); - for (int i = 0; i < getState().sources.size(); i++) { - URLReference source = getState().sources.get(i); - String sourceType = getState().sourceTypes.get(i); - getWidget().addSource(source.getURL(), sourceType); + final VMediaBase widget = getWidget(); + final AbstractMediaState state = getState(); + + setAltText(state.altText); // must do before loading sources + widget.setAutoplay(state.autoplay); + widget.setMuted(state.muted); + widget.setControls(state.showControls); + + if (event.hasPropertyChanged("sources")) { + widget.removeAllSources(); + for (int i = 0; i < state.sources.size(); i++) { + URLReference source = state.sources.get(i); + String sourceType = state.sourceTypes.get(i); + widget.addSource(source.getURL(), sourceType); + } + widget.load(); } - setAltText(getState().altText); } @Override diff --git a/client/src/com/vaadin/client/ui/VMediaBase.java b/client/src/com/vaadin/client/ui/VMediaBase.java index 8d40775c8d..b77e8bb161 100644 --- a/client/src/com/vaadin/client/ui/VMediaBase.java +++ b/client/src/com/vaadin/client/ui/VMediaBase.java @@ -18,12 +18,16 @@ package com.vaadin.client.ui; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.MediaElement; +import com.google.gwt.dom.client.NodeList; +import com.google.gwt.dom.client.SourceElement; +import com.google.gwt.dom.client.Text; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.Widget; public abstract class VMediaBase extends Widget { private MediaElement media; + private Text altText; /** * Sets the MediaElement that is to receive all commands and properties. @@ -44,7 +48,12 @@ public abstract class VMediaBase extends Widget { } public void setAltText(String alt) { - media.appendChild(Document.get().createTextNode(alt)); + if (altText == null) { + altText = Document.get().createTextNode(alt); + media.appendChild(altText); + } else { + altText.setNodeValue(alt); + } } public void setControls(boolean shouldShowControls) { @@ -59,8 +68,21 @@ public abstract class VMediaBase extends Widget { media.setMuted(mediaMuted); } + public void removeAllSources() { + NodeList<com.google.gwt.dom.client.Element> l = media + .getElementsByTagName(SourceElement.TAG); + for (int i = l.getLength() - 1; i >= 0; i--) { + media.removeChild(l.getItem(i)); + } + + } + + public void load() { + media.load(); + } + public void addSource(String sourceUrl, String sourceType) { - Element src = Document.get().createElement("source").cast(); + Element src = Document.get().createElement(SourceElement.TAG).cast(); src.setAttribute("src", sourceUrl); src.setAttribute("type", sourceType); media.appendChild(src); diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java index 6f9fd6da88..4d61fba429 100644 --- a/client/src/com/vaadin/client/ui/VScrollTable.java +++ b/client/src/com/vaadin/client/ui/VScrollTable.java @@ -3056,7 +3056,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets, .hasNext(); columnIndex++) { if (it.next() == this) { break; - } + } } } final int cw = scrollBody.getColWidth(columnIndex); @@ -3266,10 +3266,9 @@ public class VScrollTable extends FlowPanel implements HasWidgets, } if (col.hasAttribute("width")) { - final String widthStr = col.getStringAttribute("width"); // Make sure to accomodate for the sort indicator if // necessary. - int width = Integer.parseInt(widthStr); + int width = col.getIntAttribute("width"); int widthWithoutAddedIndent = width; // get min width with indent, no padding @@ -3301,12 +3300,25 @@ public class VScrollTable extends FlowPanel implements HasWidgets, // save min width without indent c.setWidth(widthWithoutAddedIndent, true); } + } else if (col.hasAttribute("er")) { + c.setExpandRatio(col.getFloatAttribute("er")); + } else if (recalcWidths) { c.setUndefinedWidth(); + + } else { + boolean hadExpandRatio = c.getExpandRatio() > 0; + boolean hadDefinedWidth = c.isDefinedWidth(); + if (hadExpandRatio || hadDefinedWidth) { + // Someone has removed a expand width or the defined + // width on the server side (setting it to -1), make the + // column undefined again and measure columns again. + c.setUndefinedWidth(); + c.setExpandRatio(0); + refreshContentWidths = true; + } } - if (col.hasAttribute("er")) { - c.setExpandRatio(col.getFloatAttribute("er")); - } + if (col.hasAttribute("collapsed")) { // ensure header is properly removed from parent (case when // collapsing happens via servers side api) diff --git a/client/src/com/vaadin/client/ui/VTextArea.java b/client/src/com/vaadin/client/ui/VTextArea.java index 6e93a076d9..45e0532451 100644 --- a/client/src/com/vaadin/client/ui/VTextArea.java +++ b/client/src/com/vaadin/client/ui/VTextArea.java @@ -18,6 +18,7 @@ package com.vaadin.client.ui; import com.google.gwt.core.client.Scheduler; import com.google.gwt.dom.client.Style.Overflow; +import com.google.gwt.dom.client.Style.WhiteSpace; import com.google.gwt.dom.client.TextAreaElement; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; @@ -62,6 +63,120 @@ public class VTextArea extends VTextField { getTextAreaElement().setRows(rows); } + @Override + public void setSelectionRange(int pos, int length) { + super.setSelectionRange(pos, length); + final String value = getValue(); + /* + * Align position to index inside string value + */ + int index = pos; + if (index < 0) { + index = 0; + } + if (index > value.length()) { + index = value.length(); + } + // Get pixels count required to scroll textarea vertically + int scrollTop = getScrollTop(value, index); + int scrollLeft = -1; + /* + * Check if textarea has wrap attribute set to "off". In the latter case + * horizontal scroll is also required. + */ + if (!isWordwrap()) { + // Get pixels count required to scroll textarea horizontally + scrollLeft = getScrollLeft(value, index); + } + // Set back original text if previous methods calls changed it + if (!isWordwrap() || index < value.length()) { + setValue(value, false); + } + /* + * Call original method to set cursor position. In most browsers it + * doesn't lead to scrolling. + */ + super.setSelectionRange(pos, length); + /* + * Align vertical scroll to middle of textarea view (height) if + * scrolling is reqiured at all. + */ + if (scrollTop > 0) { + scrollTop += getElement().getClientHeight() / 2; + } + /* + * Align horizontal scroll to middle of textarea view (widht) if + * scrolling is reqiured at all. + */ + if (scrollLeft > 0) { + scrollLeft += getElement().getClientWidth() / 2; + } + /* + * Scroll if computed scrollTop is greater than scroll after cursor + * setting + */ + if (getElement().getScrollTop() < scrollTop) { + getElement().setScrollTop(scrollTop); + } + /* + * Scroll if computed scrollLeft is greater than scroll after cursor + * setting + */ + if (getElement().getScrollLeft() < scrollLeft) { + getElement().setScrollLeft(scrollLeft); + } + } + + /* + * Get horizontal scroll value required to get position visible. Method is + * called only when text wrapping is off. There is need to scroll + * horizontally in case words are wrapped. + */ + private int getScrollLeft(String value, int index) { + String beginning = value.substring(0, index); + // Compute beginning of the current line + int begin = beginning.lastIndexOf('\n'); + String line = value.substring(begin + 1); + index = index - begin - 1; + if (index < line.length()) { + index++; + } + line = line.substring(0, index); + /* + * Now <code>line</code> contains current line up to index position + */ + setValue(line.trim(), false); // Set this line to the textarea. + /* + * Scroll textarea up to the end of the line (maximum possible + * horizontal scrolling value). Now the end line becomes visible. + */ + getElement().setScrollLeft(getElement().getScrollWidth()); + // Return resulting horizontal scrolling value. + return getElement().getScrollLeft(); + } + + /* + * Get vertical scroll value required to get position visible + */ + private int getScrollTop(String value, int index) { + /* + * Trim text after position and set this trimmed text if index is not + * very end. + */ + if (index < value.length()) { + String beginning = value.substring(0, index); + setValue(beginning, false); + } + /* + * Now textarea contains trimmed text and could be scrolled up to the + * top. Scroll it to maximum possible value to get end of the text + * visible. + */ + getElement().setScrollTop(getElement().getScrollHeight()); + // Return resulting vertical scrolling value. + return getElement().getScrollTop(); + } + private class MaxLengthHandler implements KeyUpHandler, ChangeHandler { @Override @@ -154,13 +269,18 @@ public class VTextArea extends VTextField { if (wordwrap) { getElement().removeAttribute("wrap"); getElement().getStyle().clearOverflow(); + getElement().getStyle().clearWhiteSpace(); } else { getElement().setAttribute("wrap", "off"); getElement().getStyle().setOverflow(Overflow.AUTO); + getElement().getStyle().setWhiteSpace(WhiteSpace.PRE); } - if (BrowserInfo.get().isOpera()) { + if (BrowserInfo.get().isOpera() + || (BrowserInfo.get().isWebkit() && wordwrap)) { // Opera fails to dynamically update the wrap attribute so we detach // and reattach the whole TextArea. + // Webkit fails to properly reflow the text when enabling wrapping, + // same workaround Util.detachAttach(getElement()); } this.wordwrap = wordwrap; diff --git a/client/src/com/vaadin/client/ui/VTextField.java b/client/src/com/vaadin/client/ui/VTextField.java index 9b85dd22da..60dc5a8f2a 100644 --- a/client/src/com/vaadin/client/ui/VTextField.java +++ b/client/src/com/vaadin/client/ui/VTextField.java @@ -450,4 +450,8 @@ public class VTextField extends TextBoxBase implements Field, ChangeHandler, this.inputPrompt = inputPrompt; } + protected boolean isWordwrap() { + String wrap = getElement().getAttribute("wrap"); + return !"off".equals(wrap); + } } diff --git a/client/src/com/vaadin/client/ui/VTree.java b/client/src/com/vaadin/client/ui/VTree.java index 809ed9c82d..624dce4f13 100644 --- a/client/src/com/vaadin/client/ui/VTree.java +++ b/client/src/com/vaadin/client/ui/VTree.java @@ -189,7 +189,7 @@ public class VTree extends FocusElementPanel implements VHasDropHandler, * handler, other browsers handle it correctly when using a key down * handler */ - if (BrowserInfo.get().isGecko() || BrowserInfo.get().isOpera()) { + if (BrowserInfo.get().isGecko()) { addKeyPressHandler(this); } else { addKeyDownHandler(this); diff --git a/client/src/com/vaadin/client/ui/VUI.java b/client/src/com/vaadin/client/ui/VUI.java index b627d4a2a9..b07593896f 100644 --- a/client/src/com/vaadin/client/ui/VUI.java +++ b/client/src/com/vaadin/client/ui/VUI.java @@ -53,7 +53,8 @@ import com.vaadin.shared.ui.ui.UIConstants; */ public class VUI extends SimplePanel implements ResizeHandler, Window.ClosingHandler, ShortcutActionHandlerOwner, Focusable, - HasResizeHandlers, HasScrollHandlers { + com.google.gwt.user.client.ui.Focusable, HasResizeHandlers, + HasScrollHandlers { private static int MONITOR_PARENT_TIMER_INTERVAL = 1000; @@ -437,7 +438,7 @@ public class VUI extends SimplePanel implements ResizeHandler, @Override public void focus() { - getElement().focus(); + setFocus(true); } /** @@ -462,4 +463,24 @@ public class VUI extends SimplePanel implements ResizeHandler, return addHandler(scrollHandler, ScrollEvent.getType()); } + @Override + public int getTabIndex() { + return FocusUtil.getTabIndex(this); + } + + @Override + public void setAccessKey(char key) { + FocusUtil.setAccessKey(this, key); + } + + @Override + public void setFocus(boolean focused) { + FocusUtil.setFocus(this, focused); + } + + @Override + public void setTabIndex(int index) { + FocusUtil.setTabIndex(this, index); + } + } diff --git a/client/src/com/vaadin/client/ui/VWindow.java b/client/src/com/vaadin/client/ui/VWindow.java index bd9493c761..fd2a701334 100644 --- a/client/src/com/vaadin/client/ui/VWindow.java +++ b/client/src/com/vaadin/client/ui/VWindow.java @@ -22,6 +22,9 @@ import java.util.Comparator; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Position; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.FocusEvent; @@ -35,6 +38,7 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.BrowserInfo; @@ -423,6 +427,36 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, // Remove window from windowOrder to avoid references being left // hanging. windowOrder.remove(this); + + /* + * If the window has a RichTextArea and the RTA is focused at the time + * of hiding in IE8 only the window will have some problems returning + * the focus to the correct place. Curiously the focus will be returned + * correctly if clicking on the "close" button in the window header but + * closing the window from a button for example in the window will fail. + * Symptom described in #10776 + * + * The problematic part is that for the focus to be returned correctly + * an input element needs to be focused in the root panel. Focusing some + * other element apparently won't work. + */ + if (BrowserInfo.get().isIE8()) { + fixIE8FocusCaptureIssue(); + } + } + + private void fixIE8FocusCaptureIssue() { + Element e = DOM.createInputText(); + Style elemStyle = e.getStyle(); + elemStyle.setPosition(Position.ABSOLUTE); + elemStyle.setLeft(-10, Unit.PX); + elemStyle.setWidth(0, Unit.PX); + elemStyle.setHeight(0, Unit.PX); + + Element rootPanel = RootPanel.getBodyElement(); + rootPanel.appendChild(e); + e.focus(); + rootPanel.removeChild(e); } /** For internal use only. May be removed or replaced in the future. */ diff --git a/client/src/com/vaadin/client/ui/audio/AudioConnector.java b/client/src/com/vaadin/client/ui/audio/AudioConnector.java index c7d20ef585..5a90cab09d 100644 --- a/client/src/com/vaadin/client/ui/audio/AudioConnector.java +++ b/client/src/com/vaadin/client/ui/audio/AudioConnector.java @@ -30,23 +30,6 @@ import com.vaadin.ui.Audio; public class AudioConnector extends MediaBaseConnector { @Override - public void onStateChanged(StateChangeEvent stateChangeEvent) { - super.onStateChanged(stateChangeEvent); - - Style style = getWidget().getElement().getStyle(); - - // Make sure that the controls are not clipped if visible. - if (getState().showControls - && (style.getHeight() == null || "".equals(style.getHeight()))) { - if (BrowserInfo.get().isChrome()) { - style.setHeight(32, Unit.PX); - } else { - style.setHeight(25, Unit.PX); - } - } - } - - @Override protected Widget createWidget() { return GWT.create(VAudio.class); } @@ -55,4 +38,35 @@ public class AudioConnector extends MediaBaseConnector { protected String getDefaultAltHtml() { return "Your browser does not support the <code>audio</code> element."; } + + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + super.onStateChanged(stateChangeEvent); + + // Opera (12.14) has a bug where an audio element w/o controls is shown + // as 150x300px, which is not usually desired. However, in order to show + // the error/alt message, we only do this in the exact situation. + if (BrowserInfo.get().isOpera() + && stateChangeEvent.hasPropertyChanged("showControls")) { + Style style = getWidget().getElement().getStyle(); + if (!getState().showControls) { + if (isUndefinedHeight() && isUndefinedWidth() + && getWidget().getOffsetHeight() == 150 + && getWidget().getOffsetWidth() == 300) { + // only if no size set and 150x300 + style.setWidth(0, Unit.PX); + style.setHeight(0, Unit.PX); + } + } else { + // clear sizes if it's supposed to be undefined + if (isUndefinedHeight()) { + style.clearHeight(); + } + if (isUndefinedWidth()) { + style.clearWidth(); + } + } + } + } + } diff --git a/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java b/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java index 014ea849a2..772419e730 100644 --- a/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java +++ b/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java @@ -143,11 +143,13 @@ public class CheckBoxConnector extends AbstractFieldConnector implements return; } + getState().checked = getWidget().getValue(); + // Add mouse details MouseEventDetails details = MouseEventDetailsBuilder .buildMouseEventDetails(event.getNativeEvent(), getWidget() .getElement()); - getRpcProxy(CheckBoxServerRpc.class).setChecked(getWidget().getValue(), + getRpcProxy(CheckBoxServerRpc.class).setChecked(getState().checked, details); } diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index c8210e3a09..4f0ea2de37 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -421,10 +421,6 @@ public class UIConnector extends AbstractSingleComponentContainerConnector DOM.sinkEvents(getWidget().getElement(), Event.ONKEYDOWN | Event.ONSCROLL); - // iview is focused when created so element needs tabIndex - // 1 due 0 is at the end of natural tabbing order - DOM.setElementProperty(getWidget().getElement(), "tabIndex", "1"); - RootPanel root = RootPanel.get(rootPanelId); // Remove the v-app-loading or any splash screen added inside the div by @@ -437,6 +433,10 @@ public class UIConnector extends AbstractSingleComponentContainerConnector root.add(getWidget()); + // Set default tab index before focus call. State change handler + // will update this later if needed. + getWidget().setTabIndex(1); + if (applicationConnection.getConfiguration().isStandalone()) { // set focus to iview element by default to listen possible keyboard // shortcuts. For embedded applications this is unacceptable as we |