Use first commit title for multi-commit PRs and fix auto-focus title field#36606
Conversation
When opening a PR from a branch with multiple commits, use the first (oldest) commit's message as the default title instead of the branch name. Also add autofocus to the title input so it receives focus when the PR form is toggled visible. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the compare/PR-creation flow so multi-commit PRs default their title from the oldest commit (instead of the branch name), and improves UX by auto-focusing the title input when the PR form is shown.
Changes:
- Set default PR title for multi-commit compares to the oldest commit’s summary.
- Add
autofocusto the issue/PR title field in the shared new issue/PR form template. - Add an integration test covering multi-commit PR title prefilling behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| routers/web/repo/compare.go | Changes default PR title derivation to use the oldest commit summary when multiple commits exist. |
| templates/repo/issue/new_form.tmpl | Adds autofocus to the title <input> used by both new issue and new PR forms. |
| tests/integration/compare_test.go | Adds an integration test intended to validate multi-commit PR title prefilling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… test - Set a known commit_summary for the first commit instead of relying on implicit default from testEditFileToNewBranch - Assert that PR title equals the expected oldest commit title instead of only checking what it is not Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Regarding autofocus, I see there is a |
|
Analysis by Claude: Why
|
The data-global-init handler fires on page load when the element is still hidden (tw-hidden), making the focus() call a no-op. The toggle handler in common-button.ts already focuses [autofocus] elements when the panel becomes visible, so use that instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
As per above, I've removed the broken |
It isn't broken. It is designed to move the cursor to the end of the title. When the title in the issue has a value, set the text cursor at the end of the text. (#30090) Not only one user asks for this. |
Try on main branch, this JS autofocus is not working at all. Cursor is already at the end on this branch. BTW I think the best autofocus variant would be with selection of the whole |
Ar you sure?
|
|
regarless of the current issue, I question that "autofocus on end of input" is good behaviour. Is the most common use case really to append to the title? I think a much more common use case would be to replace the title, so a full selection autofous may make more sense imho. Personally i don't really care much about this so I can keep the "end" behaviour. in 99% of cases I keep the original PR title I had written earlier. |
Have you read #30090 ? 30090 is the real use case. And not only one user asked for this behavior, for example: @tyroneyeh #36322 ef649c8 |
|
I think it's weak use case, but I wont chase that topic futher, so lets keep it focusing at the end of the text. |
Restore initInputAutoFocusEnd using an IntersectionObserver so it works both when the input is immediately visible (new issue page) and when it starts hidden and is later toggled visible (PR form on compare page). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Autofocus is back with The behaviour of "last element" is also restored, but is not doing anything useful because issue/pr title can only be once on the page. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment was marked as resolved.
This comment was marked as resolved.
Use registerGlobalInitFunc instead of registerGlobalSelectorFunc for better performance, and rely on native autofocus + show-panel handler instead of a separate data-autofocus-on-show-panel mechanism. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
all fixed now and tested. |
|
If you want to do more edits, do them now. |
|
By your approach, the cursor flickers. Because by using "autofocus", the element is focused in first time. But the "move to end" happens some time later after DOM ready. It's up to you |
The new changes just cause flickers. I insist on that my code is already good enough. If you don't like the "init name", you can change it to others you like. But the approach is almost the perfect one. I don't see why you still use "JS disabled" as a reason, we all know that Gitea won't work without JS nowadays. |
|
Reverted to JS focus again, it can not be solved cleanly with native autofocus. |





Fixes: #34865