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

Blur previous element when interacting with Cesium canvas. #8662

Merged
merged 3 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Change Log
==========

### 1.68.0 - 2020-05-01
emackey marked this conversation as resolved.
Show resolved Hide resolved

##### Fixes :wrench:

* Interacting with the Cesium canvas will now blur the previously focused element. This prevents unintended modification of input elements when interacting with the globe.

### 1.67.0 - 2020-03-02

##### Breaking Changes :mega:
Expand Down
13 changes: 13 additions & 0 deletions Source/Widgets/CesiumWidget/CesiumWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ import getElement from '../getElement.js';
canvas.onselectstart = function() {
return false;
};

// Interacting with a canvas does not automatically blur the previously focused element.
// This leads to unexpected interaction if the last element was an input field.
// For example, clicking the mouse wheel could lead to the value in the field changing
// unexpectedly. The solution is to blur whatever has focus as soon as canvas interaction begins.
function blurActiveElement() {
if (canvas !== canvas.ownerDocument.activeElement) {
canvas.ownerDocument.activeElement.blur();
}
}
canvas.addEventListener('mousedown', blurActiveElement);
canvas.addEventListener('pointerdown', blurActiveElement);

element.appendChild(canvas);

var innerCreditContainer = document.createElement('div');
Expand Down