-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fullscreen search modal #18
Conversation
FYI I created a new directory |
3a25cd7
to
13058ca
Compare
I just rebased and force-pushed, I hope it's ok. We can now try the changes by using Docpress's demo: 617f339. |
Let me implement the |
13058ca
to
6a0257e
Compare
Done. I’ve also made a few improvements, please take a look. |
Nice, much better! I think we can polish a bit more: removing the rounded corner + avoiding the scrolling of the main view. The docsearch category meta tag is live so I think we can now implement the column layout: every page is guaranteed to have a category (it falls back to |
Algolia DocSearch has already added this functionality by toggling the |
… On Sun, Oct 27, 2024 at 3:24 PM Muhammad ***@***.***> wrote:
avoiding the scrolling of the main view
Algolia DocSearch has already added this functionality by toggling the
DocSearch--active class on the <body> tag, but it doesn’t seem to be
working
—
Reply to this email directly, view it on GitHub
<#18 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHVQRQHSJS3RU7FERFAUB3Z5TZRLAVCNFSM6AAAAABQQCWNYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBQGA2DINRTGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I tried to follow the approach you used with MenuModal, but the issue with DocSearchModal is that when we click the The DocSearchModal & it's children (e.g. the Cancel button) are created dynamically, I don't know how we can add an event listener to the |
I think we can use our keydown listener to add our own CSS class to html.
…On Sun, Oct 27, 2024 at 3:29 PM Muhammad ***@***.***> wrote:
I tried to follow the approach you used with MenuModal, but the issue with
DocSearchModal is that when we click the Cancel button, the class doesn’t
get removed.
—
Reply to this email directly, view it on GitHub
<#18 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHVQRTQ5HJGFGPHZD36DG3Z5T2DLAVCNFSM6AAAAABQQCWNYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBQGA2DMMRTGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Yes, we can and it works to toggle the class. |
…zammi/full-screen-search
@brillout, Please take a look at my latest commits |
if (!isClosed()) return | ||
toggle() | ||
if (isButton) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd refactor this a bit; it's a bit difficult to understand. How about onDocsearchModalOpen()
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a user opens the docsearch modal using the hotkeys, we only need to add the class, we don't need to call
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'k', ctrlKey: true }))
because useDocSearchKeyboardEvents()
handles that.
Otherwise, the browser will throw an error : Uncaught RangeError: Maximum call stack size exceeded
in the console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, the logic seems accurate. What I meant is to refactor it to make it a little bit less convoluted.
if (isButton) { | ||
window.dispatchEvent(new KeyboardEvent('keydown', { key: 'k', ctrlKey: true })) | ||
} | ||
document.documentElement.classList.add('DocSearch--active') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment about this.
@@ -5,24 +5,31 @@ import { assert } from '../utils/client' | |||
|
|||
function closeDocsearchModal() { | |||
if (isClosed()) return | |||
toggle() | |||
document.documentElement.classList.remove('DocSearch--active') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd refactor this a bit; let's collocate this line next to its add()
counterpart.
|
||
function isClosed() { | ||
const test1 = !document.body.classList.contains('DocSearch--active') | ||
const test1 = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use an assert()
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this : 993b47c ?
Nice, looks it's working 💯 |
No description provided.