Open a long chat with enough content to scroll well below the top.
Click copy on a response or code block in an environment that uses the fallback clipboard path.
Confirm the chat stays at the same scroll position after the copy succeeds.
Screenshots or Videos
Not included for this small utility fix.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/23371
**Author:** [@suyua9](https://github.com/suyua9)
**Created:** 4/3/2026
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `fix/copy-selection-scrolltop-suyua9`
---
### 📝 Commits (1)
- [`b9952ec`](https://github.com/open-webui/open-webui/commit/b9952ec2887f8798daf100d970ae42f1c86bbab3) fix: preserve scroll position during fallback copy
### 📊 Changes
**1 file changed** (+18 additions, -2 deletions)
<details>
<summary>View changed files</summary>
📝 `src/lib/utils/index.ts` (+18 -2)
</details>
### 📄 Description
# Pull Request Checklist
- [x] **Target branch:** Verify that the pull request targets the `dev` branch.
- [x] **Description:** Provide a concise description of the changes made in this pull request down below.
- [x] **Changelog:** Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
- [ ] **Documentation:** No docs repo change needed for this small bug fix.
- [x] **Dependencies:** No new or upgraded dependencies.
- [x] **Testing:** I manually tested the fix in a long chat, verified copy actions no longer jump the viewport, and ran `git diff --check`.
- [x] **Agentic AI Code:** I manually reviewed and tested the final patch before opening this PR.
- [x] **Code review:** I performed a self-review of the code change.
- [x] **Design & Architecture:** The change stays inside the existing shared clipboard fallback path and does not add new settings.
- [x] **Git Hygiene:** This PR is a single logical change rebased onto `dev`.
- [x] **Title Prefix:** `fix`
# Changelog Entry
### Description
- Preserve the current viewport when Open WebUI falls back to the textarea-based clipboard copy path.
### Added
- None.
### Changed
- Restore the prior scroll position and focused element after fallback copy completes.
### Deprecated
- None.
### Removed
- None.
### Fixed
- Prevent inline code, code block, and response copy actions from jumping long chats back to the top when `navigator.clipboard` is unavailable.
### Security
- None.
### Breaking Changes
- **BREAKING CHANGE**: None.
---
### Additional Information
- Refs #23363
- Manual test steps:
1. Open a long chat with enough content to scroll well below the top.
2. Click copy on a response or code block in an environment that uses the fallback clipboard path.
3. Confirm the chat stays at the same scroll position after the copy succeeds.
### Screenshots or Videos
- Not included for this small utility fix.
### Contributor License Agreement
- [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/23371
Author: @suyua9
Created: 4/3/2026
Status: ❌ Closed
Base:
dev← Head:fix/copy-selection-scrolltop-suyua9📝 Commits (1)
b9952ecfix: preserve scroll position during fallback copy📊 Changes
1 file changed (+18 additions, -2 deletions)
View changed files
📝
src/lib/utils/index.ts(+18 -2)📄 Description
Pull Request Checklist
devbranch.git diff --check.dev.fixChangelog Entry
Description
Added
Changed
Deprecated
Removed
Fixed
navigator.clipboardis unavailable.Security
Breaking Changes
Additional Information
Screenshots or Videos
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.