Skip to content

Commit

Permalink
[Mobile] - Autocomplete - Fix regression related to the Enter key code (
Browse files Browse the repository at this point in the history
#45997)

* Mobile - Fix issue on mobile and the autocomplete feature / slash inserter where the enter key would fail to create the block and instead it creates a new Paragraph block

* Add KeyCodes to the AztecView mock
  • Loading branch information
Gerardo Pacheco authored Nov 28, 2022
1 parent 21fc1d3 commit a4eab09
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/react-native-aztec/src/AztecView.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,5 +284,6 @@ class AztecView extends Component {
const RCTAztecView = requireNativeComponent( 'RCTAztecView', AztecView );

AztecView.InputState = AztecInputState;
AztecView.KeyCodes = KEYCODES;

export default AztecView;
1 change: 1 addition & 0 deletions packages/rich-text/src/component/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ export class RichText extends Component {
this.customEditableOnKeyDown?.( {
preventDefault: () => undefined,
...event,
key: RCTAztecView.KeyCodes[ event?.keyCode ],
} );

this.handleDelete( event );
Expand Down
5 changes: 4 additions & 1 deletion test/native/__mocks__/@wordpress/react-native-aztec/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import { omit } from 'lodash';
*/
import { forwardRef, useImperativeHandle, useRef } from '@wordpress/element';

// Preserve the mock of AztecInputState to be exported with the AztecView mock.
// Preserve the mock of AztecInputState and AztecKeyCodes to be exported with the AztecView mock.
const AztecInputState = jest.requireActual( '@wordpress/react-native-aztec' )
.default.InputState;
const AztecKeyCodes = jest.requireActual( '@wordpress/react-native-aztec' )
.default.KeyCodes;

const UNSUPPORTED_PROPS = [ 'style' ];

Expand Down Expand Up @@ -50,5 +52,6 @@ const RCTAztecView = ( { accessibilityLabel, text, ...rest }, ref ) => {

const AztecView = forwardRef( RCTAztecView );
AztecView.InputState = AztecInputState;
AztecView.KeyCodes = AztecKeyCodes;

export default AztecView;

0 comments on commit a4eab09

Please sign in to comment.