Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Disabled auto-completion while user doing backspacing

  • Loading branch information
mahmoud-adam85 authored and Tim Palade committed Apr 18, 2018
1 parent c779e8b commit 0f7138ac562dc9ca7d6461be419dd02573788307
Showing with 13 additions and 1 deletion.
  1. +13 −1 Cliqz/Search/CliqzSearchViewController.swift
@@ -48,7 +48,13 @@ class CliqzSearchViewController : UIViewController, KeyboardHelperDelegate, UIAl

weak var delegate: SearchViewDelegate?

var searchQuery: String? = nil
var lastSearchQuery: String? = nil

var searchQuery: String? = nil {
willSet {
lastSearchQuery = searchQuery
}
}

var profile: Profile

@@ -232,6 +238,12 @@ extension CliqzSearchViewController {
//MARK: - Autocomplete Notification
extension CliqzSearchViewController {
@objc func autocomplete(_ notification: Notification) {

if let searchQuery = searchQuery, let lastSearchQuery = lastSearchQuery, searchQuery.count < lastSearchQuery.count {
// don't call auto complete if user is backspacing
return
}

if let str = notification.object as? String {
delegate?.autoCompeleteQuery(str)
}

0 comments on commit 0f7138a

Please sign in to comment.