gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

RichText not focusable in InnerBlocks

Open MatzeKitt opened this issue 9 months ago • 1 comments

Description

When adding a new RichText component. via the editor.BlockEdit filter after the BlockEdit, I cannot select it if the block is an inner block. On clicking on the block, the selection quickly changes to the parent block and then back to the inner block, but not to my RichText component.

import { RichText } from '@wordpress/block-editor';
import { createHigherOrderComponent } from '@wordpress/compose';
import { addFilter } from '@wordpress/hooks';
import { __ } from '@wordpress/i18n';

const addControls = createHigherOrderComponent( ( BlockEdit ) => ( props ) => {
	return (
		<>
			<BlockEdit { ...props } />

			<RichText
				allowedFormats={ [
					'core/bold',
					'core/italic',
					'core/underline',
				] }
				identifier="notes"
				placeholder={ __( 'Notes …' ) }
				style={ { position: 'relative', zIndex: 100 } }
				tagName="div"
			/>
		</>
	);
} );

addFilter( 'editor.BlockEdit', 'rh/block-notes/add-controls', addControls );

(The style attribute is just for a better usability in this demo to prevent it from being overlapped by the inline block inserter.)

Step-by-step reproduction instructions

  1. Use the code from above
  2. Try to select/focus the RichText element of an inner block (e.g. inside a paragraph of a group block)

Screenshots, screen recording, code snippet

https://github.com/WordPress/gutenberg/assets/1018979/4464537a-826c-4ab9-9bce-41d2f9224322

Environment info

  • WordPress 6.5

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

MatzeKitt avatar May 08 '24 12:05 MatzeKitt

Reproducibility was confirmed using a similar code.

image

I don't know if it is directly related to this issue. When I enter text into Notes, the following error appears on the browser console.

Uncaught TypeError: o is not a function
    at onChange (block-editor.min.js?ver=868d782fcb169133c92b:41:48611)
    at rich-text.min.js?ver=dd125966cf6cc0394ae0:2:28756
    at batch (data.min.js?ver=e6595ba1a7cd34429f66:2:20762)
    at Object.batch (data.min.js?ver=e6595ba1a7cd34429f66:2:22124)
    at w (rich-text.min.js?ver=dd125966cf6cc0394ae0:2:28737)
    at HTMLDivElement.a (rich-text.min.js?ver=dd125966cf6cc0394ae0:2:25467)

image

megane9988 avatar May 10 '24 02:05 megane9988

The same problem applies to all blocks in the widget area.

MatzeKitt avatar Jun 05 '24 05:06 MatzeKitt

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

github-actions[bot] avatar Jul 06 '24 00:07 github-actions[bot]

Still relevant.

MatzeKitt avatar Jul 06 '24 07:07 MatzeKitt

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.

github-actions[bot] avatar Aug 06 '24 00:08 github-actions[bot]

Still relevant.

MatzeKitt avatar Aug 06 '24 04:08 MatzeKitt

I was able to reproduce the same problem.

Navigation with the arrow keys also does not function properly.

torounit avatar Aug 07 '24 15:08 torounit

I'm seeing this pop up on many sites where custom blocks use rich-text in innerblocks.

Just wondering if this change has triggered something. https://github.com/WordPress/gutenberg/pull/60936

flickerbox-tom avatar Sep 13 '24 16:09 flickerbox-tom