Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 0bbd20f

Browse files
JanLaussmannmhevery
authored andcommitted
fix(mobile-ng-click): prevent unwanted opening of the soft keyboard
Ghost clicks are busted but the corresponding form elements are still focused. This means that for example on smartphones the soft keyboard will be opened. This pull request prevents the unwanted opening of the soft keyboard.
1 parent 3fdbe81 commit 0bbd20f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/ngMobile/directive/ngClick.js

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement',
135135
// If we didn't find an allowable region, bust the click.
136136
event.stopPropagation();
137137
event.preventDefault();
138+
139+
// Blur focused form elements
140+
event.target && event.target.blur();
138141
}
139142

140143

test/ngMobile/directive/ngClickSpec.js

+3
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ describe('ngClick (mobile)', function() {
211211
expect($rootScope.count1).toBe(1);
212212

213213
time = 90;
214+
// Verify that it is blured so we don't get soft-keyboard
215+
element1[0].blur = jasmine.createSpy('blur');
214216
browserTrigger(element1, 'click', [], 10, 10);
217+
expect(element1[0].blur).toHaveBeenCalled();
215218

216219
expect($rootScope.count1).toBe(1);
217220

0 commit comments

Comments
 (0)