Splitting this out from #1960
In the Classic Editor, the post title field gets auto-focused when it's empty. This happens either if it's a new post or an existing post with an empty title and actually doesn't have anything to do with the post status or visibility. To see the current behavior:
- create a new post
- observe the post title field gets autofocused
- edit a draft or published post that don't have a title
- observe the post title field gets autofocused
- edit an existing post that has a title
- observe the post title doesn't get autofocused
The simple logic for this behavior can be seen in an inline JavaScript ( 😬 ) at https://core.trac.wordpress.org/browser/trunk/src/wp-admin/edit-form-advanced.php?rev=42343#L830 and basically is:
- if it's not mobile
- if the post supports a title
- if the title ie an empty string
- then, focus the title field
This simple behavior has been there for years and I guess the original intent was to focus the title field when creating a new post. This makes sense to me, as when clicking on "New post", the workflow is clear and there's one, specific, main, task to accomplish: start writing.
I'm not so sure the title field should be autofocused in all the other cases (draft / published post with empty title, etc.) as in these cases leaving the title empty might be a deliberate user choice and moving focus could be a bit too wide assumption.
Splitting this out from #1960
In the Classic Editor, the post title field gets auto-focused when it's empty. This happens either if it's a new post or an existing post with an empty title and actually doesn't have anything to do with the post status or visibility. To see the current behavior:
The simple logic for this behavior can be seen in an inline JavaScript ( 😬 ) at https://core.trac.wordpress.org/browser/trunk/src/wp-admin/edit-form-advanced.php?rev=42343#L830 and basically is:
This simple behavior has been there for years and I guess the original intent was to focus the title field when creating a new post. This makes sense to me, as when clicking on "New post", the workflow is clear and there's one, specific, main, task to accomplish: start writing.
I'm not so sure the title field should be autofocused in all the other cases (draft / published post with empty title, etc.) as in these cases leaving the title empty might be a deliberate user choice and moving focus could be a bit too wide assumption.