Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rte toolbar bug #1567

Closed
alimajed93 opened this issue Nov 8, 2018 · 8 comments
Closed

rte toolbar bug #1567

alimajed93 opened this issue Nov 8, 2018 · 8 comments

Comments

@alimajed93
Copy link

Hello all,

I am using the latest grapesjs stable version (40) and I noticed the following bug in the rich text editor: If the user drags and drop a rich text editor into the canvas, clicks on it and tries to clone it per example (or any action in the toolbar like delete, ...), no action will happen. The user has to select another block per example, or just click outside the text editor, then clicks again on the text editor, to be able to perform the toolbar actions.

Any idea what could be causing this issue? I started noticing it after moving to the new version, I was before using v17.

Thank you for your help.

@artf
Copy link
Member

artf commented Nov 8, 2018

Yeah, that happens because of this check, being in editing mode we need to prevent some actions (eg. clicking canc/backspace triggers the same command). Probably we need to put some kind of force option

@alimajed93
Copy link
Author

alimajed93 commented Dec 11, 2018

Hi @artf ,

Oh I see.
Can you please give me some examples of why we added this check? I mean what problems were we having and were solved by this check?

Thanks.

@artf
Copy link
Member

artf commented Dec 11, 2018

Without those checks, for instance, in text editing mode CTRL+C/V instead of just copying/pasting the selected text will copy/paste the component. This is why I suggest a kind of force option

@arthuralmeidap
Copy link
Contributor

Hi @artf ,

I have been thinking about this problem.
What do you think about adding a validation, when a shortcut is pressed like ctrl+c, to run only when the editor is not on editing mode or the canvas has not the input focused?
It would be to change this line https://github.com/artf/grapesjs/blob/dev/src/keymaps/index.js#L148 and add this validation.
Any thoughts on this?

@arthuralmeidap
Copy link
Contributor

arthuralmeidap commented Feb 14, 2019

@artf , Just to make myself clear about the last comment.

The fix would be move this validation here https://github.com/artf/grapesjs/blob/dev/src/commands/view/ComponentDelete.js#L5

from the command classes and move to the https://github.com/artf/grapesjs/blob/dev/src/keymaps/index.js#L148.

That would make less duplicate code, and will fix the problem.

It would deactivate the key bindings when the editor is on editing mode.

Can you see any problems on this approach?

@artf
Copy link
Member

artf commented Feb 16, 2019

@arthuralmeidap actually you're right, all current default keymaps should work like this (be off when something is editing, like text component or input element).

Can you see any problems on this approach?

The only possible caveats I see in this approach is what to do when someone wants to trigger a keymap even in editing mode. For this case, I'd suggest adding a new options argument in Keymaps.add method, eg:

add(id, keys, handler, opts = {}) {
	...
		if (ableToRun || opts.force) {
			typeof handler == 'object' ? handler.run(editor) : handler(editor);
			...
		}
	...
}

@arthuralmeidap
Copy link
Contributor

PR: #1800

@artf artf closed this as completed in ec735ef Feb 18, 2019
@artf artf added this to To do in Release v0.14.55 via automation Feb 18, 2019
@artf artf moved this from To do to Done in Release v0.14.55 Feb 18, 2019
@lock
Copy link

lock bot commented Feb 21, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the outdated label Feb 21, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Feb 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

3 participants