Unable to select text of author's name on edition page after author "button" accidentally clicked
Problem
While creating #13617, I discovered that it's possible to get the page into a state where it's impossible to select the text associated with the author's name in the link.
Reproducing the bug
- Go to https://openlibrary.org/books/OL60300732M
- (Accidentally) click blue dot next to author's name
- Attempt to select text of edition title and author's name
- Click "Clear selections" on omni bar
- Attempt to select text again
- Expected behavior: Edition title and author's name gets selected together as a single string of text
- Actual behavior: author's name is silently skipped in both cases, even after the little magic button is deselected
Context
- Browser (Chrome, Safari, Firefox, etc): Chrome
- OS (Windows, Mac, etc): Mac
- Logged in (Y/N): Y
- Environment (prod, dev, local): prod
Breakdown
Implementation Details (for maintainers)
Requirements Checklist
- [ ]
Related files
Stakeholders
- @lokesh
Instructions for Contributors
- Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.
Thank you @tfmorris for submitting this issue!
Context
This is the Integrated Librarian Environment (ILE) selection tool. The "little magic button" is the blue-dot .ile-select-handle prepended to author links (added only when addHandle: true):
https://github.com/internetarchive/openlibrary/blob/30022332bd7dabb2dd4a87d2a75dbae3e8893629/openlibrary/plugins/openlibrary/js/ile/utils/SelectionManager/SelectionManager.js#L448-L460
Clicking it calls toggleSelected, which (via setElementSelectionAttributes) sets el.draggable = true on the enclosing <a> so the link becomes drag-and-droppable while selected:
https://github.com/internetarchive/openlibrary/blob/30022332bd7dabb2dd4a87d2a75dbae3e8893629/openlibrary/plugins/openlibrary/js/ile/utils/SelectionManager/SelectionManager.js#L175-L185
Setting draggable=true makes the browser start a native drag operation on mousedown+drag over that element instead of a text-selection drag — which is why the author name gets "silently skipped" while selected.
The part that matches this report's second symptom ("even after the little magic button is deselected") looks like a genuine bug: IntegratedLibrarianEnvironment.reset() — called by "Clear Selections" — only strips the ile-selected CSS class, but never calls setElementSelectionAttributes(el, false), so draggable (and the bound dragstart/dragend listeners) are never reset to false:
https://github.com/internetarchive/openlibrary/blob/30022332bd7dabb2dd4a87d2a75dbae3e8893629/openlibrary/plugins/openlibrary/js/ile/index.js#L57-L65
Compare with toggleSelected, which correctly pairs the class change with setElementSelectionAttributes:
https://github.com/internetarchive/openlibrary/blob/30022332bd7dabb2dd4a87d2a75dbae3e8893629/openlibrary/plugins/openlibrary/js/ile/utils/SelectionManager/SelectionManager.js#L156-L173
This selectability logic (and the "don't intercept a click if it's ending a text-selection drag" guard) was introduced by a78d3b18f ("Don't select on link clicks", 2023-05-15), and the underlying feature/file is otherwise unowned in recent history — git log/git blame on SelectionManager.js show most activity from Drini Cami (@cdrini), Mark Heiman, and Jim Champ. No duplicate or related open issue/PR was found searching issues/PRs for this behavior.
Issue Assessment
Open questions
- Should
reset()restoredraggable/listener state for every element it stripsile-selectedfrom (matching whatsetElementSelectionAttributes(el, false)does), or should selection state instead be centralized so the class and the drag attributes can never drift out of sync? - Independent of the "stuck after clear" bug: is it acceptable UX for the author link to become undraggable-as-text while actively selected (a tradeoff for enabling drag-and-drop), or should the drag affordance live only on the
.ile-select-handledot rather than the whole<a>?
Action items
- [ ] A maintainer should confirm whether the fix should live in
IntegratedLibrarianEnvironment.reset()(callsetElementSelectionAttributes(el, false)per element instead of only removing the class) or inSelectionManager.clearSelectedItems()/toggleSelecteditself.
Suggested breakdown
- [ ] Update
reset()(openlibrary/plugins/openlibrary/js/ile/index.js) to resetdraggableand remove thedragstart/dragendlisteners for every.ile-selectedelement it clears, not just the CSS class — likely by routing throughSelectionManager.setElementSelectionAttributes(el, false). - [ ] Add/extend a test in
tests/unit/js/SelectionManager.test.jsassertingdraggableisfalseand drag listeners are unbound afterclearSelectedItems()/reset(). - [ ] (Design/UX call, not code) Decide whether the drag affordance should be scoped to
.ile-select-handleinstead of the whole link, so text selection isn't affected even while an item is actively selected.
The first two sub-tasks are small and localized to one file; could be a Good First Issue once a lead confirms the intended fix approach in the first action item above.
🔔 Stakeholders
@cdrini — ILE toolbar is your area, and git blame/git log on SelectionManager.js show you as the original author of the selection/click-handling logic this bug lives in.
Full triage checklist
- [x] Triage — correct labels applied or removed
- [x] Problem / opportunity — problem is clear, audience identified, actionable
- [x] Scope — issue is well-scoped; does not try to do too many things
- [x] Justification — reasoning and impact stated; sufficient for leads to prioritize
- [x] Success & testing criteria — defines what "done" looks like, verifiable by a contributor
- [ ] Proposal & breakdown — concrete plan present; checklist actionable for a contributor
- [x] If bug: environment & repro steps — browser, version, local vs prod; steps to reproduce
- [x] Risks, concerns, open questions — identified and surfaced
- [x] Richy context — relevant code, commits, PRs reviewed; no duplicate found
- [ ] References — screenshots, designs, docs, and links present where needed
[!NOTE] This comment was automatically generated by Richy, Open Library's issue enrichment assistant, on behalf of @mekarpeles. This is NOT a sign-off. This issue needs lead review before work begins.
Hi @cdrini, @tfmorris , @mekarpeles , I would like to be assigned this issue.
I will fix this by updating reset() to call SelectionManager.setElementSelectionAttributes(el, false) for each .ile-selected element just like mentioned in the suggested breakdown. Let me know your thoughts on this.
Problem
While creating #13617, I discovered that it's possible to get the page into a state where it's impossible to select the text associated with the author's name in the link.
Reproducing the bug
- Go to https://openlibrary.org/books/OL60300732M
- (Accidentally) click blue dot next to author's name
- Attempt to select text of edition title and author's name
- Click "Clear selections" on omni bar
- Attempt to select text again
- Expected behavior: Edition title and author's name gets selected together as a single string of text
- Actual behavior: author's name is silently skipped in both cases, even after the little magic button is deselected
Context
- Browser (Chrome, Safari, Firefox, etc): Chrome
- OS (Windows, Mac, etc): Mac
- Logged in (Y/N): Y
- Environment (prod, dev, local): prod
Breakdown
Implementation Details (for maintainers)
I’d like to take this issue up. I’ll work on the proposed fix in reset() to properly restore the selection state, including draggable and the associated drag event listeners, and add/extend the relevant tests to verify the behavior.
I’ll also look into the UX aspect of the author link selection and report back if any additional changes seem necessary.