Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement preventScroll for focusable elements #2234

Merged
merged 1 commit into from Jul 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions appinventor/appengine/src/com/google/appinventor/YaClient.gwt.xml
Expand Up @@ -103,6 +103,16 @@
<when-type-assignable class="com.google.gwt.user.client.rpc.RemoteService" />
</generate-with>

<replace-with class="com.google.appinventor.client.utils.FocusImplStandard">
<when-type-is class="com.google.gwt.user.client.ui.impl.FocusImpl"/>
<when-property-is name="user.agent" value="gecko1_8"/>
</replace-with>

<replace-with class="com.google.appinventor.client.utils.FocusImplSafari">
<when-type-is class="com.google.gwt.user.client.ui.impl.FocusImpl"/>
<when-property-is name="user.agent" value="safari"/>
</replace-with>

<!-- English language, independent of country -->
<extend-property name="locale" values="en"/>
<!-- Simplified Chinese -->
Expand Down
@@ -0,0 +1,21 @@
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2020 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

package com.google.appinventor.client.utils;

import com.google.gwt.dom.client.Element;

/**
* FocusImplSafari extends the GWT class of the same name in order to pass
* the preventScroll option when an element is focused programmatically.
*/
public class FocusImplSafari extends com.google.gwt.user.client.ui.impl.FocusImplSafari {
@Override
public native void focus(Element elem)/*-{
$wnd.setTimeout(function() {
elem.focus({'preventScroll': true});
}, 0);
}-*/;
}
@@ -0,0 +1,19 @@
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright 2020 MIT, All rights reserved
// Released under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

package com.google.appinventor.client.utils;

import com.google.gwt.dom.client.Element;

/**
* FocusImplStandard extends the GWT class of the same name in order to pass
* the preventScroll option when an element is focused programmatically.
*/
public class FocusImplStandard extends com.google.gwt.user.client.ui.impl.FocusImplStandard {
@Override
public native void focus(Element elem)/*-{
elem.focus({'preventScroll': true});
}-*/;
}