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

Quick bar loses selection #3132

Closed
twschiller opened this issue Apr 9, 2022 · 5 comments
Closed

Quick bar loses selection #3132

twschiller opened this issue Apr 9, 2022 · 5 comments
Labels
bug Something isn't working specification required

Comments

@twschiller
Copy link
Contributor

twschiller commented Apr 9, 2022

Steps to reproduce (to verify)

  • Select text
  • Hit Quick Bar short cut
  • Select text passed to the extension is blank

Possible causes:

  • If PixieBrix does not already have access to the page, it can't track the selection prior to hitting the keyboard shortcut. Hitting Cmd+K my unselect the text before PixieBrix has a chance to find the selection

cc @MMirandi - I think you were seeing this?

@twschiller twschiller added bug Something isn't working specification required labels Apr 9, 2022
@fregante
Copy link
Collaborator

fregante commented Apr 9, 2022

The logic to preserve the selection is managed by KBarToggle:

Does/should useAutoShow also trigger that?

function useAutoShow(): void {
const { query } = useKBar();
useEventListener(QUICKBAR_EVENT_NAME, () => {
query.toggle();
});

@twschiller twschiller added this to the 1.6.0 milestone Apr 10, 2022
@twschiller
Copy link
Contributor Author

Good catch, @fregante. I think that's worth a try. If that's the case, the buggy behavior should occur reliably on pages that PixieBrix does not have access to until the user toggles the KBar with the keyboard shortcut

@fregante
Copy link
Collaborator

I can't replicate the issue:

Screen.Recording.3.mov

You can see that the content script doesn't load until I press cmd-k because that's when the (unrelated) "Action" button appears.

However I'm seeing some strange behavior when the editor is open:

  • the extension doesn't appear in the dropdown
  • the quickbar does not open later (cmd-k, esc, cmd-k)
Screen.Recording.5.mov

The logic to preserve the selection is managed by KBarToggle:

I checked now: The selection controller is called even by the auto show.

The only incorrect behavior is that it always calls restore when the content script is loaded, because showing === false. That's not a problem though, because it exits immediately with a noop in that case:

restore(): void {
if (!selectionOverride) {
return;
}

@fregante
Copy link
Collaborator

It's somewhat possible that this is entirely caused by

The selection is saved into memory so if the second selection.save() call happens when the selection is moved, then the restoration will also not work. But then again I can't replicate it.

@fregante
Copy link
Collaborator

Closing as resolved as this was likely a consequence of multiple kbar injections. Reopen if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working specification required
Projects
None yet
Development

No branches or pull requests

2 participants