Skip to content

Commit 8b1b580

Browse files
committed
Fixed browser back when removing queries
When a user holds down backspace on removing the last suggested query, a browser may go back to a previous page. This PR will prevent default behaviour when cursor index is at 0.
1 parent 7f0c11a commit 8b1b580

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/angular-advanced-searchbox.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ angular.module('angular-advanced-searchbox', [])
171171
var cursorPosition = getCurrentCaretPosition(e.target);
172172

173173
if (e.which == 8) { // backspace
174-
if (cursorPosition === 0)
174+
if (cursorPosition === 0) {
175+
e.preventDefault();
175176
$scope.editPrevious(searchParamIndex);
177+
}
176178

177179
} else if (e.which == 9) { // tab
178180
if (e.shiftKey) {

0 commit comments

Comments
 (0)