Skip to content

Commit bd12291

Browse files
committed
Fix issues with MaterialTimePicker orientation.
1 parent 7ab677c commit bd12291

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/java/gwt/material/design/addins/client/timepicker/MaterialTimePicker.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ public class MaterialTimePicker extends AbstractValueWidget<Date> implements Has
121121
private boolean detectOrientation = false;
122122
private Orientation orientation = Orientation.PORTRAIT;
123123

124+
protected HandlerRegistration orientationHandler;
125+
124126
public MaterialTimePicker() {
125127
super(Document.get().createElement("div"), AddinsCssName.TIMEPICKER, CssName.INPUT_FIELD);
126128
}
@@ -236,12 +238,14 @@ public void setOrientation(Orientation orientation) {
236238
public void setDetectOrientation(boolean detectOrientation) {
237239
this.detectOrientation = detectOrientation;
238240

239-
window().off("resize.lolliclock-orientation");
241+
if(orientationHandler != null) {
242+
orientationHandler.removeHandler();
243+
orientationHandler = null;
244+
}
240245

241246
if(detectOrientation) {
242-
window().on("resize.lolliclock-orientation", e -> {
247+
orientationHandler = com.google.gwt.user.client.Window.addResizeHandler(resizeEvent -> {
243248
detectAndApplyOrientation();
244-
return true;
245249
});
246250
detectAndApplyOrientation();
247251
}

0 commit comments

Comments
 (0)