BUGFIX: Properly pause mousetrap during inline editing #3498
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes: #3099
The problem
We have a
Hotkeys
saga that initializes aMousetrap
(see: https://www.npmjs.com/package/mousetrap). The saga does so once for the host frame. For the guest frame it then initializes a separateMousetrap
every time, a document has been loaded.In theory this should ensure that keyboard shortcuts work both in the host and in the guest frame. There's one specific scenario though in which we do not want keyboard shortcuts to work at all and that is: inline editing (basically, because typing something into CKEditor would otherwise trigger all kinds of unintended actions).
This is why the
Hotkeys
saga tracks amousetrapPaused
flag. The idea is to pause the mousetrap every time the content canvas signals that there's inline editing going on:neos-ui/packages/neos-ui-sagas/src/UI/Hotkeys/index.js
Lines 39 to 41 in ef72c79
#3099 describes that the hot keys do not work inside the guest frame at all. I found that this is due to
mousetrapPaused
always beingtrue
.Looking at the declaration of the action creator for
SET_CURRENTLY_EDITED_PROPERTY_NAME
:neos-ui/packages/neos-ui-redux-store/src/UI/ContentCanvas/index.ts
Line 59 in ef72c79
I could see that the payload for
SET_CURRENTLY_EDITED_PROPERTY_NAME
is not an object with a keypropertyName
, but a string that represents just the property name. So, the conditionaction.payload.propertyName !== ''
is always true, becauseaction.payload.propertyName
is alwaysundefined
.The solution
I changed the condition for
mousetrapPaused
toto match the intended semantics with the action creator definition for
SET_CURRENTLY_EDITED_PROPERTY_NAME
. Now keyboard shortcuts work as intended in the guest frame, but are ignored if there's inline editing going on.