diff options
author | John Ahlroos <john@vaadin.com> | 2013-08-08 11:05:38 +0300 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2013-08-08 13:17:30 +0300 |
commit | 5fb05e84c80931fcaa9929ad556a20f5316e06a8 (patch) | |
tree | bd4d977bd653a16b0dd38bc9d09d8e38d2cd9c4f /client | |
parent | 11f8811eb0f7a306c403d36ab45f5d8658d7a164 (diff) | |
download | vaadin-framework-5fb05e84c80931fcaa9929ad556a20f5316e06a8.tar.gz vaadin-framework-5fb05e84c80931fcaa9929ad556a20f5316e06a8.zip |
Fixes Button icon alt text not being updated #12333
Change-Id: I23a26fbc5281e76792e257321d96f3d30a8bc2b2
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/Icon.java | 11 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/button/ButtonConnector.java | 13 |
2 files changed, 19 insertions, 5 deletions
diff --git a/client/src/com/vaadin/client/ui/Icon.java b/client/src/com/vaadin/client/ui/Icon.java index 5ba3cc6eeb..9d5829c079 100644 --- a/client/src/com/vaadin/client/ui/Icon.java +++ b/client/src/com/vaadin/client/ui/Icon.java @@ -53,4 +53,15 @@ public class Icon extends UIObject { } } + /** + * Sets the alternate text for the icon. + * + * @param alternateText + * with the alternate text. + */ + public void setAlternateText(String alternateText) { + getElement().setAttribute("alt", + alternateText == null ? "" : alternateText); + } + } diff --git a/client/src/com/vaadin/client/ui/button/ButtonConnector.java b/client/src/com/vaadin/client/ui/button/ButtonConnector.java index fff983c168..a6630f28b9 100644 --- a/client/src/com/vaadin/client/ui/button/ButtonConnector.java +++ b/client/src/com/vaadin/client/ui/button/ButtonConnector.java @@ -24,7 +24,6 @@ import com.google.gwt.event.dom.client.FocusEvent; import com.google.gwt.event.dom.client.FocusHandler; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; import com.vaadin.client.EventHelper; import com.vaadin.client.MouseEventDetailsBuilder; import com.vaadin.client.communication.StateChangeEvent; @@ -84,13 +83,12 @@ public class ButtonConnector extends AbstractComponentConnector implements if (getIcon() != null) { if (getWidget().icon == null) { getWidget().icon = new Icon(getConnection()); - Element iconElement = getWidget().icon.getElement(); - iconElement.setAttribute("alt", getState().iconAltText); - - getWidget().wrapper.insertBefore(iconElement, + getWidget().wrapper.insertBefore( + getWidget().icon.getElement(), getWidget().captionElement); } getWidget().icon.setUri(getIcon()); + getWidget().icon.setAlternateText(getState().iconAltText); } else { if (getWidget().icon != null) { getWidget().wrapper.removeChild(getWidget().icon @@ -120,6 +118,11 @@ public class ButtonConnector extends AbstractComponentConnector implements } } + if (getWidget().icon != null + && stateChangeEvent.hasPropertyChanged("iconAltText")) { + getWidget().icon.setAlternateText(getState().iconAltText); + } + getWidget().clickShortcut = getState().clickShortcutKeyCode; } |