Select some text in the paragraph below.
Placement
placement is a preference. A toolbar over a selection on the first line of a page has no room above it, so it flips below, then to the sides, and finally clamps itself inside the viewport. When the anchor scrolls entirely out of view the toolbar hides rather than sitting clamped against the edge of the window, acting on text nobody can see.
Focus
Three rules, all of which exist because the toolbar's main consumer is a text editor:
- Appearing never moves focus. The editor keeps the caret and the selection.
- Pressing a button never moves focus. The toolbar cancels
mousedown, which is the event that would focus the button and blur the editor. Theclickstill fires. Text fields inside the toolbar (a link URL, say) are exempt, since they genuinely need focus. - Keyboard users get in deliberately. Call the exposed
focus()from your editor's shortcut (Alt+F10 is the common one), and return focus to the editor yourself onclose.