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
Fix formatting keyboard shortcuts on non-text elements #13299
Conversation
Plugin builds for a2a96e8 are ready 🛎️!
|
Size Change: -15 B (0%) Total Size: 2.71 MB ℹ️ View Unchanged
|
Nice find! 😅 Looking at this const hasText = selectedElements.find(({ type }) => type === 'text'); What do you think? |
Yes, that would be great! I am updating accordingly into the new commit. But I'm facing an issue in unit-test after I have added brackets:
I am looking into unit-test for the component. Any suggestion? |
Looks like the dummy text element used in the tests is missing web-stories-wp/packages/story-editor/src/components/panels/design/textStyle/test/textStyle.js Lines 86 to 101 in e5978b9
Fixing that makes the tests pass |
If attribute `type: 'text'` does not present it will `hasText()` will return `false` and following three dependent test will fails: - should set the text bold when the key command is pressed - should set the text underline when the key command is pressed - should set the text italics when the key command is pressed Co-Authored-By: Pascal Birchler <pascal.birchler@gmail.com>
Co-Authored-By: Pascal Birchler <pascal.birchler@gmail.com>
Thank you so much 👍🏻 |
hasText()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Context
The goal of the PR is to fix #13281.
Summary
Editor crashes when using a keyboard shortcut not applicable to a shape element. For example, enter
cmd+b
,cmd+i
orcmd+u
on a shape element.This is happening because call to a callback function
hasText
has missing round brackets.hasText
is never executed and following code-block never executes:web-stories-wp/packages/story-editor/src/components/panels/design/textStyle/useRichTextFormatting.js
Lines 189 to 191 in 258b77e
So, it do not return when text is not present.
Relevant Technical Choices
To-do
Fixed with: 2ea1c81
User-facing changes
Not applicable.
Testing Instructions
This PR can be tested by following these steps:
Reviews
No.
Does this PR change what data or activity we track or use?
No.
Does this PR have a legal-related impact?
No.
Checklist
Not applicable.
Fixes #13281