Show "Generate" instead of "Regenerate" when post body is empty#717
Conversation
The toolbar button was labeled "Regenerate" whenever the post had a title, even if the post body was empty. With no content the AI has nothing to work from, so showing "Regenerate" was misleading. Now "Regenerate" only appears when the post has both a title and some body content. When the body is empty the button always reads "Generate", making the prerequisite clear to users.
|
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 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. |
|
@i-anubhav-anand This is another PR that duplicates work done in an existing PR (see #479). I'd suggest as you look to pick up Issues, don't work on Issues that already have a PR attached as it just makes things more difficult for maintainers. If you have a different approach to what's already there, that should be a conversation that happens either on that PR or on the Issue first. |
Problem
Fixes #391
The toolbar button was labelled Regenerate whenever the post had a title, even when the post body was empty. With no content the AI has nothing to work from, so "Regenerate" was misleading — it implied a previous generation existed and would be replaced.
Solution
Read
getEditedPostContent()in theuseSelectcall and only label the button "Regenerate" when the post has both a title and body content. When the body is empty the button always reads Generate, making the prerequisite clear to users.Changes
src/experiments/title-generation/components/TitleToolbar.tsxcontenttouseSelectreturn valuehasContentfrom the post bodyhasTitle && hasContentinstead ofhasTitleto decide the "Regenerate" labelcontentvariable insidehandleGenerate/handleRegeneratetopostContentto avoid shadowing the new reactive stateTesting