Skip to content

Commit

Permalink
Merge pull request #18 from noriyotcp/disable-tooltip-on-mobile
Browse files Browse the repository at this point in the history
Disable tooltip on mobile
  • Loading branch information
noriyotcp authored Oct 4, 2024
2 parents a0cff41 + 6cc718a commit bde41ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions assets/js/detectOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export function detectOS() {
return "Unknown";
}

export function isDesktop() {
return detectOS() === "macOS" || detectOS() === "Windows" || detectOS() === "Linux";
}

export function isMobile() {
return detectOS() === "iOS" || detectOS() === "Android";
}
8 changes: 6 additions & 2 deletions assets/js/hotkeys.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isMobile } from "./detectOS.js";
import { isDesktop } from "./detectOS.js";
import { setupFocusHotkeys } from "./setupFocusHotkeys.js";
import { setupSearchHotkeys } from "./setupSearchHotkeys.js";
import { setupHotkeysPopoverHotkeys } from "./setupHotkeysPopoverHotKeys.js";
Expand All @@ -7,9 +7,13 @@ document.addEventListener("DOMContentLoaded", function () {
// setup to search
const searchIcon = document.querySelector("button.search__toggle");
if (searchIcon) {
if (!isMobile()) {
if (isDesktop()) {
searchIcon.setAttribute("tooltip", "cmd/ctrl + k to open, esc to close");
searchIcon.setAttribute("tooltip-position", "left");
} else {
// Disable tooltip on mobile
searchIcon.removeAttribute("tooltip");
searchIcon.removeAttribute("tooltip-position");
}

setupSearchHotkeys(searchIcon);
Expand Down

0 comments on commit bde41ea

Please sign in to comment.