naturalcrit / homebrewery

Create authentic looking D&D homebrews using only markdown
https://homebrewery.naturalcrit.com
MIT License
1.07k stars 326 forks source link

Ability to close search / replace bar #3645

Open brandinchase1 opened 3 weeks ago

brandinchase1 commented 3 weeks ago

Your idea:

When you open the search or replace bar (Ctrl+F and Ctrl+Shift+F respectively) there is no way that I could find to close the search bar.

dbolack-ab commented 3 weeks ago

The search bar responds to the escape key or by clicking outside of it on my system. Is it behaving differently for you?

brandinchase1 commented 3 weeks ago

I tried escape and it worked. And I retried it and clicking outside of it works as well. I have just had a couple instances where it doesn't go away when clicking and I'm not sure how to replicate it now. At the very least, it might be helpful to add an close button or a note mentioning the escape key

Gazook89 commented 3 weeks ago

Maybe one day we can utilize the openDialog addon for codemirror to make a fancier search box: https://codemirror.net/5/doc/manual.html#addon_dialog

brandinchase1 commented 3 weeks ago

https://github.com/user-attachments/assets/36fe0a42-fe53-443b-aaee-a60570d4c9b0

I found a way to replicate it

Gazook89 commented 3 weeks ago

Ah, so if you highlight (edit: CLICK INTO) the search tip text, you can't click or esc to close the search box. Weird.

brandinchase1 commented 3 weeks ago

You can use either but you have to click back in the search bar before you are able to. And I didn't know that esc was an option so it wasn't really intuitive for me to click back on the box. I also know that it blocks the first line of text so when I was trying to edit my first line it was more of problem.

Gazook89 commented 3 weeks ago

I was impressed that you were able to get your editor window to be scrolled so close to the end of your text. I can't get my scroll to anything less than ~4 lines of text, no matter how i scrunch and stretch my window or how many lines of text i have. It seems it's possible to position the search box at the bottom as just an option on the Codemirror Search library, so maybe we could do that.

That said, it seems like it is a bug/oversight on the codemirror 5 library itself. I looked through the Search library source but couldn't spot exactly how the dismissal of the sear box works or where i'd tweak it.

Others can chime in, but my gut feeling is that this is not likely going to be fixed unless someone spots a really easy fix.

brandinchase1 commented 3 weeks ago

Do you think we could intercept this line somehow and modify the cm.phrase to include "Hit escape to close"

https://github.com/codemirror/codemirror5/blob/48d159a49b1db89523df7834cb18b46ac142764b/addon/search/search.js#L210

Gazook89 commented 3 weeks ago

I don't think that really solves the problem, though. If clicking anywhere else on the screen doesn't dismiss it as probably 99% of people would expect, that means it's already too late for hitting esc-- doing so won't do anything. So it'd be more confusing that it isn't working. You'd need a note that says "if you can't dismiss this, click back into the search box and then click anywhere else".

The only really fix I think is to make it so it is dismissable regardless of whether the search box is in focus or not.

5e-Cleric commented 6 days ago

We could add a closing button to it, it is using the space for one after all, a little X button at the end should be no problem.