Code Block: Add Tab and Shift+Tab indentation support#71056
Code Block: Add Tab and Shift+Tab indentation support#71056Infinite-Null wants to merge 8 commits intoWordPress:trunkfrom
Tab and Shift+Tab indentation support#71056Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @wclear. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
This looks like based on the video is working well! |
|
I think we're moving in the right direction, but PR still needs some work. Notes
I think we can resolve the first point by only allowing indent/outdent when there's a text selection. This is how GitHub handles similar logic in the comment textarea. ScreeencastCleanShot.2025-08-06.at.12.29.15.mp4 |
|
Hi @Mamaduka, Screen.Recording.2025-08-07.at.11.57.01.AM.mov |
…locks using `Shift+Tab`
|
Hi @Mamaduka, Screen.Recording.2025-08-08.at.11.43.47.AM.movScreen.Recording.2025-08-08.at.11.44.12.AM.mov |
|
Thanks for the follow-ups, @Infinite-Null! I'll try to test this properly later today. Meanwhile, here are some general notes:
|
Tab and Shift+Tab indentation support
|
Hi @Mamaduka, Thank you for the feedback. I have moved the logic to the |
Mamaduka
left a comment
There was a problem hiding this comment.
Thanks for the follow-ups, @Infinite-Null!
I think indentation works mostly well, but there are still some quirks that would be nice to polish.
It's easier to showcase via screencast:
CleanShot.2025-08-22.at.15.20.26.mp4
| }; | ||
| }, [] ); | ||
|
|
||
| return { ref }; |
There was a problem hiding this comment.
Suggestion (non-blocking): We can just return ref here; there's no need to wrap it in the object and destruct later.
What?
Closes #15791.
Closes #37336
Enhances the Code block so that pressing Tab indents the current line or selected text, and pressing Shift+Tab de-indents it.
Why?
Previously, pressing Tab inside a Code block moved focus to the next UI element, making proper code indentation impossible.
This update captures Tab and Shift+Tab key events, allowing for natural code editing and improving the experience for developers and anyone writing code snippets.
Testing Instructions
CodeblockScreencast
Before
Screen.Recording.2025-08-06.at.12.28.31.PM.mov
After
Screen.Recording.2025-08-08.at.11.43.47.AM.mov