Skip to content

Commit

Permalink
view search will focus on the search input if you're already on that …
Browse files Browse the repository at this point in the history
…page
  • Loading branch information
jcsalterego committed Dec 21, 2024
1 parent 701ec77 commit b62ef3a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Sky/Scripts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,10 @@ class Scripts {
)
}

static func focusSearch() -> String {
return JsLoader.loadScriptContents(
"Scripts/focus_search", [:]
)
}

}
18 changes: 11 additions & 7 deletions Sky/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,18 @@ class ViewController: NSViewController {
}

@IBAction func actionViewSearch(_ sender: Any?) {
self.webView.evaluateJavaScript(
Scripts.navigateNavbar(
checkLoadNew: false,
label: "Search",
index: 1,
url: SkyUrls.search
if webView.url!.absoluteString == SkyUrls.search {
self.webView.evaluateJavaScript(Scripts.focusSearch())
} else {
self.webView.evaluateJavaScript(
Scripts.navigateNavbar(
checkLoadNew: false,
label: "Search",
index: 1,
url: SkyUrls.search
)
)
)
}
}

@IBAction func actionViewFeeds(_ sender: Any?) {
Expand Down

0 comments on commit b62ef3a

Please sign in to comment.