Link panel should close when clicking outside of it and outside of the editor (i.e. in the body of the webpage). Otherwise people will leave orphan panels open and, as the content/geometry of the page changes, the panels will lose their anchor and float weirdly without making any sense.
Related issue: https://github.com/ckeditor/ckeditor5-link/issues/3.
Shouldn't this be relative to the selection?
Yes, @fredck, the panel should be in sync with the selection in the editor. And it works in the current implementation.
But this issue is about what happens when the user clicks somewhere out of the editor, like a different input in the form, some page navigation, whatever, really.
Clicking somewhere on a page means blurring the editor UI. So a more general way of thinking about it would be related to focus manager.
Clicking outside of the panel and outside of the editor should close the panel and not restore editor focus (e.g. someone click on input outside the editor and want to write something)? But clicking on some editor UI element (e.g. toolbar) should close the panel and restore the editor focus?
Yes.
Basically, the panel should not care about focus in such case. The click itself will handle this... when outside it'll cause the editor to blur... when in the editor UI, will cause the focus to be restored.
It is not so easy, because focus manager has information that panel is open and when panel will be closed FM will try to restore focus on editor.
FM is not supposed to manipulate the focus. It just registers some UI elements and provides an API to tell "hey, this div, which is somewhere in DOM belongs to the editor". And that's it. v4 works like that.
Other components of the editor will then use that API and check whether the focus is still in the editor or not, instead of checking focus on editable. This way editable can be blurred, but FM knows that some fancy panel not belonging to editable which has been just clicked is considered a part of editor (it has been registered) so it tells other components (like floating toolbar) that the focus is still there. It's a synthetic focus.
Yep, you are right guys.
Fixed by ckeditor/ckeditor5-link#34.
Most helpful comment
Yes.