Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group hints together outside of document's body #3284

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion source/changelog.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -948,4 +948,6 @@ enabling its customization.")
(:li "The height of the " (:nxref :class-name 'message-buffer) " and "
(:nxref :class-name 'status-buffer) " can be dynamically set and its UI
elements are scaled accordingly.")
(:li "Remove experimental support for WebExtensions via " (:code "libnyxt") ".")))
(:li "Remove experimental support for WebExtensions via " (:code "libnyxt") ".")
(:li "Fix bug where the CSS of a webpage sets " (:code "display") " to " (:code "none")
" for elements matching hints.")))
13 changes: 8 additions & 5 deletions source/mode/hint.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,20 @@ A positive value shifts to the bottom.")
(ps:@ element text-content) hint)
element))

(let ((fragment (ps:chain document (create-document-fragment)))
(let ((hints-parent (ps:chain document (create-element "div")))
(hints (ps:lisp (list 'quote hints)))
(nyxt-identifiers (ps:lisp (list 'quote nyxt-identifiers))))
(dotimes (i (length hints))
(let* ((hint (aref hints i))
(nyxt-identifier (aref nyxt-identifiers i))
(element (nyxt/ps:rqs-nyxt-id document nyxt-identifier)))
(ps:chain element (set-attribute "nyxt-hint" hint))
(ps:chain fragment (append-child (create-hint-overlay element hint)))
(ps:chain hints-parent (append-child (create-hint-overlay element hint)))
(when (ps:lisp (show-hint-scope-p (find-submode 'hint-mode)))
(ps:chain element class-list (add "nyxt-element-hint")))))
(ps:chain document body (append-child fragment))
(setf (ps:@ hints-parent id) "nyxt-hints"
(ps:@ hints-parent style) "all: unset !important;")
(ps:chain document body parent-node (insert-before hints-parent (ps:@ document body next-sibling)))
;; Returning fragment makes WebKit choke.
nil))

Expand Down Expand Up @@ -203,8 +205,9 @@ A positive value shifts to the bottom.")
hintable-elements)))))

(define-parenscript-async remove-hint-elements ()
(ps:dolist (element (nyxt/ps:rqsa document ":not(.nyxt-search-node) > .nyxt-hint"))
(ps:chain element (remove)))
(ps:let ((hints-parent (nyxt/ps:qs-id document "nyxt-hints")))
(ps:when hints-parent
(ps:chain hints-parent (remove))))
(when (ps:lisp (show-hint-scope-p (find-submode 'hint-mode)))
(ps:dolist (element (nyxt/ps:rqsa document ".nyxt-element-hint"))
(ps:chain element class-list (remove "nyxt-element-hint")))))
Expand Down