Repository navigation
fix: autofocus only new, empty posts - #823
Merged
Merged
Conversation
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/823")Built from ac09603 |
dcalhoun
force-pushed
the
fix/autofocus-only-new-empty-posts
branch
from
October 23, 2026 15:14
a88431e to
2bdf395
Compare
Autofocus was meant for new posts, as in WP Admin, but checked only for empty content, so it also raised the keyboard on existing posts with empty content and on local drafts with only a title. It now matches the web editor's rule for new posts: no server ID and an empty title and content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV
GBKitGlobal sends the web editor postId.toInt(), so a negative ID a host converted with toUInt() reaches it as a new post. Autofocus read the same value as a server ID, so the two disagreed about whether the post was new. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV
… web editor Autofocus and GBKitGlobal each converted postId on their own, so they could disagree about whether a post is new. One property now decides, with null for a new post as the Post.id TODO intends; only the wire encoding still uses -1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WP Admin focuses a clean auto-draft, not a post with no ID and a blank title and content, so the comparison misled readers about which posts autofocus targets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dcalhoun
force-pushed
the
fix/autofocus-only-new-empty-posts
branch
from
October 23, 2026 15:40
2bdf395 to
ac09603
Compare
dcalhoun
marked this pull request as ready for review
October 23, 2026 15:51
Contributor
|
Claude had one medium finding, but it's not something that really needs to be addressed, imo.
|
Member
Author
|
@nbradbury I don't believe it is all that valuable to address here. I do not believe any post passes negative IDs aside from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Limit auto-focus to new, empty posts.
Why?
Aligns more closely with the WP Admin experience.
How?
isNewEmptyPostcheck for iOS and AndroidTesting Instructions
Test the demo app on iOS and Android with a site added through the demo app's login, rather than the built-in wp-env site, which has no Browse button on Android. Use a device or a simulator/emulator with the software keyboard enabled.
.setTitle("Trip notes")toapplyDemoAppDefaultsinios/Demo-iOS/Sources/Views/SitePreparationView.swift. On Android, change.setTitle("")to.setTitle("Trip notes")inSitePreparationViewModel.kt. Tap Start, and verify that the keyboard doesn't open. On trunk, it does..setShouldHideTitle(true)toapplyDemoAppDefaultson iOS. On Android, change.setHideTitle(false)to.setHideTitle(true). Tap Start, and verify that the keyboard opens with the caret in the content. This PR shouldn't change this case.Revert the demo app edits afterward.
Accessibility Testing Instructions
N/A, no navigation changes.
Screenshots or screencast
N/A, no visual changes.
AI-generated details
Native autofocus (#191) was meant for new posts but checked only for empty content. It now uses the same rule as the web editor's new posts (#794): no server ID (missing or ≤ 0), and a blank title and content.
isNewEmptyPosttoEditorConfigurationon iOS and Android.focus(force:)and Android's autofocus on load use it.focus(force: true)still overrides it.isNewEmptyPostandGBKitGlobalshare an internalserverPostId(nullfor a new post), so autofocus and the web editor can't disagree about whether a post is new. Only the bridge'sPost.idstill encodes a new post as-1.Behavior changes
focus()call withoutforceon iOS no longer focuses an existing post with empty content.UIntnow reaches the web editor as-1rather than its own negative value. Both mean a new post.The native calls stay because core's title focus only moves DOM focus. iOS's
becomeFirstResponder()and Android'srequestFocus()andshowSoftInputraise the keyboard, and GBK'seditor.focus()covers editors with a hidden title, which core never focuses.Testing
isNewEmptyPoston both platforms, and for the Android-1mapping inGBKitGlobalTest. The iOS package tests and Android library unit tests pass, and both linters pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01YNDBX7RNXn3NsfDuV1PkNV