Skip to content

Fix horizontal scroll reset in Web UI when clicking a link in a table cell - #108941

Merged
alexey-milovidov merged 2 commits into
masterfrom
play-fix-horizontal-scroll-link
Jun 30, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
play-fix-horizontal-scroll-link

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

When a result cell contained a link and the table was scrolled horizontally to the right, clicking the link (which opens in a new tab) and returning to the Web UI reset the horizontal scroll position back to the left.

The cause: selecting a cell called this.focus() on the whole query-result element. That element spans the full width with its left edge at the start of the scroll container, so the browser scrolled it into view both on focus and when the tab was re-focused on return, resetting the horizontal scroll.

The fix focuses the selected cell itself instead. Every scroll-into-view now targets the cell, which is already at the scrolled position, so the horizontal scroll is preserved. Keyboard navigation still works because keydown bubbles from the focused cell up to the listener on the component.

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixed the horizontal scroll position of the result table being reset in the Web UI when clicking a link in a cell and returning to the page.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.7.1.309 (included in 26.7 and later)

… cell

In the Web UI (`play.html`), selecting a result cell called `this.focus()`
on the whole `query-result` element. Because that element spans the full
width with its left edge at the start of the scroll container, the browser
scrolled it into view both on `focus` and when the tab was re-focused (e.g.
after opening a cell link in a new tab and returning), resetting the
horizontal scroll position back to the left.

Focus the selected cell instead. Every scroll-into-view now targets the
cell, which is already at the scrolled position, so the horizontal scroll
is preserved. Keyboard navigation still works because `keydown` bubbles
from the focused cell to the listener on the component.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1ad7652]

Summary: ✅


AI Review

Summary
  • The PR changes programs/server/play.html so result-table selection focuses the selected td instead of the whole query-result host, preserving horizontal scroll when returning from a newly opened link. I did not find a code-level regression in the changed selection or keyboard-navigation paths.
PR Metadata
  • 💡 The selected Improvement category is weaker than the actual change: this fixes user-visible Web UI misbehavior, so the category should be Bug Fix (user-visible misbehavior in an official stable release).
  • The changelog entry is required for that category and is specific enough. Suggested category replacement:
### Changelog category (leave one):
- Bug Fix (user-visible misbehavior in an official stable release)
Missing context / blind spots
  • ⚠️ I could not execute the browser scroll/focus scenario locally: no headless browser, playwright, puppeteer, or jsdom is available in this environment. A focused manual browser check or UI test would close this gap.
  • ⚠️ The direct Praktika PR report currently exposes 0 tests for commit 1ad7652f746ed27400e40b4beae17257ea0891cd, so CI does not provide behavioral evidence for the Web UI interaction.
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jun 30, 2026
The previous commit added a CSS comment containing backticks
(`.td-selected`) inside the `this.shadowRoot.innerHTML = ` template
literal of `QueryResultElement`. A backtick inside a template literal
terminates the string, so the parser closed the template early and read
the following text as JavaScript, throwing `selected is not defined` in
the constructor. This aborted construction of every `query-result`
element, so all queries failed in the Web UI (followed by a cascading
`Cannot read properties of undefined (reading 'firstChild')` in
`_clearElement`).

Drop the backticks from the comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Continue-PR status (no code changes) — head 1ad7652f74, MERGEABLE/BLOCKED, not draft.

Review state: AI Review verdict is ✅ Approve, 0 unresolved review threads, human/AI reviews clean. The only AI note is the changelog-category suggestion (Bug Fix vs Improvement), which I leave as your call.

Both CI reds are unrelated flakes — this is a static play.html (JS/HTML/CSS only) change, +33/-16, zero C++/server code:

Re-triggered both failed stress jobs (run 28451988903, --failed). No re-merge: merge-base is from today (10:26Z, <1d) and the reds are not fixable by a master merge.

@alexey-milovidov alexey-milovidov self-assigned this Jun 30, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 30, 2026
Merged via the queue into master with commit 0e738ea Jun 30, 2026
342 of 344 checks passed
@alexey-milovidov
alexey-milovidov deleted the play-fix-horizontal-scroll-link branch June 30, 2026 23:52
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 1, 2026
alexey-milovidov added a commit that referenced this pull request Jul 1, 2026
…-arrow-nav

Resolve the conflict in `programs/server/play.html` between this branch's
keyboard-navigation work and master's Web UI changes that landed in the same
area (`#108891` table count, `#108941` horizontal-scroll fix).

Both branches independently extracted the result-table cell-selection logic
into a `_selectCell` method, so the merge left two definitions. Keep master's
`_selectCell` (it additionally focuses the cell with `td.focus({ preventScroll:
true })` and manages a roving `tabindex`, which fixes the horizontal-scroll
reset from `#108941`) and drop this branch's duplicate, which was a strict
subset. The result-table keydown handler is attached to the host element and
reads `_current_selected_cell`, so master's per-cell focus composes correctly
with the arrow-key navigation added here. At the arrow-move call site, keep
master's `cell.removeAttribute('tabindex')` before `_selectCell(new_cell)` to
maintain the roving tabindex.

All of master's additions (`.database-table-count`, `td:focus { outline: none }`,
the table-count feature in `loadTables`/`loadDatabases`) and all of this
branch's features (database-panel arrow navigation, focused-row balloon,
toolbar/theme keyboard access, download-menu tab sequence) are preserved.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…tal-scroll-link

Fix horizontal scroll reset in Web UI when clicking a link in a table cell
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-arrow-nav

Resolve the conflict in `programs/server/play.html` between this branch's
keyboard-navigation work and master's Web UI changes that landed in the same
area (`ClickHouse#108891` table count, `ClickHouse#108941` horizontal-scroll fix).

Both branches independently extracted the result-table cell-selection logic
into a `_selectCell` method, so the merge left two definitions. Keep master's
`_selectCell` (it additionally focuses the cell with `td.focus({ preventScroll:
true })` and manages a roving `tabindex`, which fixes the horizontal-scroll
reset from `ClickHouse#108941`) and drop this branch's duplicate, which was a strict
subset. The result-table keydown handler is attached to the host element and
reads `_current_selected_cell`, so master's per-cell focus composes correctly
with the arrow-key navigation added here. At the arrow-move call site, keep
master's `cell.removeAttribute('tabindex')` before `_selectCell(new_cell)` to
maintain the roving tabindex.

All of master's additions (`.database-table-count`, `td:focus { outline: none }`,
the table-count feature in `loadTables`/`loadDatabases`) and all of this
branch's features (database-panel arrow navigation, focused-row balloon,
toolbar/theme keyboard access, download-menu tab sequence) are preserved.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants