hypothesis / hypothesis/product-backlog
Improve sidebar behaviour when making a new annotation
- Dominant language
- No language data
- Stars
- 122
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
_Originally reported as https://github.com/hypothesis/h/issues/3551 by @seanh._
### Problem you are trying to address
If the sidebar is already open and then you select some text in the document in order to make an annotation, the sidebar closes when you select the text and then opens again when you click the annotate button:

### Your solution
Based on previous discussion, the suggested aims for a fix are:
1. When a user clicks in the document it hides the sidebar.
2. If the user has the sidebar open and makes a new selection, don’t close the sidebar.
Possible implementation:
If there is some selected text after a click on the document has happened then don't close the sidebar. Otherwise do close the sidebar. That should mean that:
- If there is no selection and then the user clicks and drags to create a new selection, then there will be a selection so the sidebar won't close.
- If there is an existing selection and then the user clicks and drags to destroy this selection and replace it with a new selection, then there will be a selection so the sidebar won't close.
- If there is no selection and the user just clicks on the document, then there will be no selection after this click so the sidebar will close.
Potential issues with this implementation:
- If there is a selection and the user clicks on the document this will clear the selection but not make a new selection, after this click there is no selection anymore, so the sidebar will close. Did the user mean to close the sidebar? Or where they just unselecting the text, and actually they were using or reading the sidebar and still wanted it?
We _could_ decide that in order for a click to close the sidebar there has to be both no selection before and no selection after the click. Then in this case of clearing a selection the sidebar would not close (if the user were to subsequently click again then it would close). But that just reverses the problem: what if the user was trying to close the sidebar? It would be annoying that it didn't close, and the user may not realise that this is because they had to clear their selection first (the selection may not even be on screen).
- In browsers a double-click will select the word under the cursor, and a triple-click will select the paragraph. In both cases after the first click nothing is selected (yet) so the sidebar will close only to quickly open again if the user clicks the annotate button. Can we distinguish a genuine single click from the first click of a double or triple click?
Another implementation thought:
"If there is some selected text" seems to be synonymous with "the popup adder is shown", might be helpful in implementation.
For completeness I'll just suggest again that the simple behaviour _don't close the sidebar unless the user clicks the close button on the sidebar_ avoids any guessing of user intent with "if this then that except if else" type issues (but as noted in previous discussion requires actually clicking on a button rather than just anywhere on the doc).
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no files, tests, or entry points. Reproduce the sidebar behavior while clicking and selecting text in the document, then trace the existing document-click and selection handling. Done means a new selection does not close an open sidebar, while an ordinary document click still closes it, with the double- and triple-click cases resolved.
Written by the indexing model from the issue text.
Assessment
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100