Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

T/430: The BalloonToolbar should not blink when the editor receives focus #432

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

oleq
Copy link
Member

@oleq oleq commented Jul 12, 2018

Suggested merge commit message (convention)

Type: The BalloonToolbar should not blink when the editor receives focus. Closes ckeditor/ckeditor5#5480.


Additional information

Requires a small correction in the image tests https://github.com/ckeditor/ckeditor5-image/tree/t/ckeditor5-ui/430.

@oleq oleq requested review from oskarwrobel and pjasiun July 12, 2018 08:45
* it sets the {@link #_isVisibilityTogglePending} flag `true` to notify other pieces of code
* that debouncing is in progress.
*/
this._fireToggleVisibilityDebounced = ( eventName, data ) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a regular class method instead of an anonymous function assigned to the class property.

* v v | v |
* |------------------x------x----------------x-----------------------x----------------x----> [time]
* |------|----------------| |----------------|
* <200ms 200ms 200ms
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need this chart here. It basically shows how debounce is working.

this.listenTo( this, '_selectionChangeDebounced', () => {
if ( this.editor.editing.view.document.isFocused ) {
this._fireToggleVisibilityDebounced( '_selectionChangeDebounced' );
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to define the event name ('_selectionChangeDebounced') in such case? Maybe the parameter should be optional?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it is not perfectly clear to me why we need to debounce selection change since we already listen on change:range and have debouncing in toggle visibility. So what is missing in the documentation is the answer to 2 question:

  • what is the difference between '_selectionChangeDebounced' and 'change:range'?
  • why do we need debounce to be used 2 time?

// Don't reposition the toolbar when awaiting visibility toggle. It may cause unnecessary
// movement just before it disappears as a result of the toggle.
if ( this._isVisibilityTogglePending ) {
this.once( '_toggleVisibilityDebounced', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

show() method could reposition when ballon is already shown.
This listener won't be necessary then.

// Hide the toolbar when the selection is changed by a direct change or has changed to collapsed.
if ( eventName == 'change:range' ) {
if ( data.directChange || selection.isCollapsed ) {
this.hide();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if there are direct selection change and focus change withing 10ms? Since only the last event name is used, there will be no information that direct selection change happen and the panel will not be hidden?

This is a bigger problem, and the reason I am not sure about the eventName parameter. What, in general, should be used as eventName if multiple events happen? If we will use only the first or the last one we will lose some information which might be important. We could use an array, but then guess which of these events should be used might be also very tricky. This is why I think that it would be much better if the event will not say what was the reason for the change. The listener should decide what to do based on the editor state (check if the selection is collapsed and if the editor is focused).

@Reinmar
Copy link
Member

Reinmar commented Jan 28, 2020

@oleq do you want to keep this PR alive? Or could we close it and just keep the branch? I presume you're not planning to get back to this anytime soon.

@oleq
Copy link
Member Author

oleq commented Jan 29, 2020

I can still reproduce it in Letters so the issue is valid.

It's unlikely though we're going to schedule some time to work on it anytime soon.

On the third hand, I'd hate to lose the code BC I saw there's a lot of rocket science involved (research, ASCII art :P) and this could be a nice starting point in the future.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The balloon toolbar flashes in certain situations
5 participants