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

Gutenberg editor focus jumps to nearest ACF block with a WYSIWYG when entering a new line #68905

Open
3 of 6 tasks
braican opened this issue Jan 27, 2025 · 4 comments
Open
3 of 6 tasks
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.

Comments

@braican
Copy link

braican commented Jan 27, 2025

Description

When editing content with the block editor that contains an ACF block with a WYSIWYG field, hitting the enter button to open a new line after a block jumps the cursor to the end of the WYSIWYG field rather than keeping focus on the new line.

Step-by-step reproduction instructions

  1. In a fresh WP installation, install and enable ACF pro.

  2. Register a block.

    // In functions.php
    add_action( 'init', function() {
        register_block_type( __DIR__ . '/blocks/text-block');
    } );

    Within the theme, create a blocks/text-block directory and add this block.json:

    {
      "name": "acf/text",
      "title": "Text",
      "description": "Demo text block.",
      "keywords": [],
      "acf": {
        "mode": "preview",
        "renderTemplate": "text-block.php"
      },
      "supports": {}
    }

    You can also add the blocks/text-block/text-block.php file, though it can be empty.

  3. Add a new ACF field group that has a single WYSIWYG field, and assign it to the block you created above.

  4. Open a post that uses the block editor for editing. Add some text content, as well as an instance of your ACF block. Make sure the ACF block sits at least after two paragraphs.

  5. Put your cursor at the end of the first text paragraph, then hit enter. Confirm that the editor creates a new empty text block but then immediately the cursor jumps to the end of the first instance of the ACF block's WYSIWYG editor rather than staying in the new empty block.

  6. Manually click back to the previously opened block and hit the backspace button. Confirm that the block gets removed but again the cursor jumps to the end of the first instance of the ACF block's WYSIWYG editor rather than the end of the previous text block.

Screenshots, screen recording, code snippet

Google.Chrome.-.Edit.Page.Demo.page.Demo.bug.report.WordPress.2025-01-27.at.4.11.45.PM.mp4

Environment info

  • WordPress version 6.7.1
  • Theme: Twenty Twenty-Five version 1.0
  • ACF version 6.3.11
  • All browsers

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@braican braican added the [Type] Bug An existing feature does not function as intended label Jan 27, 2025
@t-hamano t-hamano added [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... Needs Testing Needs further testing to be confirmed. labels Jan 28, 2025
@t-hamano
Copy link
Contributor

If this issue does not occur with content that consists of core blocks only, the problem may be caused by a plugin.

I recommend contacting the plugin's support.

@t-hamano t-hamano added [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes. and removed Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended labels Jan 28, 2025
@braican
Copy link
Author

braican commented Jan 28, 2025

That's reasonable, and that was my first thought as well. However when I downgraded WordPress to version 6.6.2, the interaction works as expected. Here's an updated screenshare showing the interaction first with WP version 6.7 (which has the broken experience) and then with WP version 6.6.2, which works fine:

Google.Chrome.-.Dashboard.Demo.bug.report.WordPress.2025-01-28.at.8.32.56.AM.mp4

Note that to accommodate the core version switch, I also switched to using the Twenty Twenty-Four theme. The ACF version remains unchanged.

Is there any documentation you can point me to around how the block editor handles focus or callbacks for an enter keypress? Especially in relation to the update from 6.6.2 to 6.7? I've been struggling to find up-to-date resources for this type of thing.

@merlijnvanlent
Copy link

We are also experiencing this problem. But have the same issues, no up to date resources can be found.

@t-hamano
Copy link
Contributor

t-hamano commented Feb 1, 2025

However when I downgraded WordPress to version 6.6.2, the interaction works as expected.

If this is true, this issue may have occurred in Gutenberg 18.6 or later, because the Gutenberg versions that correspond to WordPress 6.6.2 are 17.8 to 18.5 (See Versions in WordPress).

If we could find out which Gutenberg version this issue occurred in, we might be able to find out the exact cause.

From what I understand, you need a paid Pro license to create blocks with ACF. I've never created a block with the ACF plugin, so I'd appreciate it if someone could investigate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Plugin Interoperability Incompatibilities between a specific plugin and the block editor. Close with workaround notes.
Projects
None yet
Development

No branches or pull requests

3 participants