-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Adding options customizing a behavior of show-hint
addon
#6467
Adding options customizing a behavior of show-hint
addon
#6467
Conversation
- closeOnCursorActivity - closeOnPick - paddingForScrollbar - moveOnOverlap
How will the dialog continue to update when, on cursoractivity, it simply doesn't close, but takes no further action? The thing you call To address the lint failure, you can add a |
- Opt-out from not needed first hint scrolling early in order to prevent reflow
@marijnh In my case, I'm taking care of updating the My issue with the current implementation was that it has been closing the dialog and opening it again after a fraction of the second. The result perceived by the user has been a flickering of the dialog so I had to avoid that. Then, you can say that, with I've called it paddingForScrollbar because I'm using this flag too for:
so this is about the right padding in order to compensate for the scrollbar. However, agree that it's not the case for:
so I've moved I've also added a check over the Please let me know what you think. P.S. I've added |
@marijnh I've also updated the description in order to reflect the current state of the PR. Thanks a lot for your feedback. |
Thanks for addressing those. I've merged this. When a regression is reported I'll ping you ;) |
Amazing, thanks a lot 🥳 Sure, in case of any errors, just let me know and I'll fix it 🙂 Should we add a description for the new options to the docs? |
I'm not sure—they seem error-prone enough to be more likely to confuse and trip-up users than to help. |
Sure, makes sense. You'd need to be aware that with
Maybe |
When working with the
show-hint
addon (very valuable in general, thanks!), I've come across situations when I had to customize its behavior.I didn't want to highly customize the internal logic so I was able to simply add options modifying some of the taken actions.
However, I've made also two improvements not being behind the options:
startScroll
insetTimeout
so it doesn't cause the forced reflow on initthis.scrollToActive()
call as it doesn't need to be scrolled to the first hint on init (especially thatselectedHint
is0
by default) and it causes the reflow as wellI'd divide the options into two groups: functional and styling ones (having a performance impact).
Functional:
closeOnCursorActivity
- disable closing the suggestions list on the cursor activity. The suggestionsul
element has been "blinking" on every cursor movement what wasn't desiredcloseOnPick
- disable closing the suggestions list on picking the item. In my use case, a user picks the suggestion, and the new suggestions list loads immediately based on the previously chosen one so, again, list blinking wasn't desiredStyling:
paddingForScrollbar
- disable adding an additional padding for the scrollbar. Computing that has been causing a very noticeable (at least in our case) force reflows by using things likeclientHeight
orgetBoundingClientRect()
. I'd prefer to disable this in order to gain performancemoveOnOverlap
- disable moving the list on overlapping the screen (horizontal or vertical). It computeshints.getBoundingClientRect()
what was also heavy performance-wise in our case. We don't need this functionality so I'd prefer to disable itAll of the options above are enabled by default so they don't affect existing users of the addon in any way.
In my particular scenario, I was able to decrease the time spent in the
show-hint
addon from (on average)> 100ms
to max11ms
.If you'd find these changes valuable, I'd be happy to merge them.
Question: these options need to be described in https://codemirror.net/doc/manual.html#addon_show-hint or it's not strictly required?
Thank you.