diff options
author | Ben Rohlfs <brohlfs@google.com> | 2023-05-04 16:14:12 +0200 |
---|---|---|
committer | Paladox none <thomasmulhall410@yahoo.com> | 2023-05-08 15:38:28 +0000 |
commit | 3ab2461a78c2963bd687bede4b21f6006e96da2c (patch) | |
tree | 570ffac296e8f6851f5e7b699ee8dbfea765b00a | |
parent | 2954269bc051d3c385d989820c8e1b237dfd2165 (diff) |
Fix focus being on the LOST diff row for image diffs
This was found using screenshot testing and looks like this:
https://imgur.com/a/ZS05wiR
The `buildSectionElement()` override is a pattern that we also use
for the binary diff builder.
Release-Notes: skip
Change-Id: I4493ea1b2280227c791c2704c112ec57d088fa71
(cherry picked from commit 36fa69d8f072f6e5c1ef1c25debea7ccb7542137)
-rw-r--r-- | polygerrit-ui/app/embed/diff/gr-diff-builder/gr-diff-builder-image.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/polygerrit-ui/app/embed/diff/gr-diff-builder/gr-diff-builder-image.ts b/polygerrit-ui/app/embed/diff/gr-diff-builder/gr-diff-builder-image.ts index 3bffe08bc0..1f7ffd38f8 100644 --- a/polygerrit-ui/app/embed/diff/gr-diff-builder/gr-diff-builder-image.ts +++ b/polygerrit-ui/app/embed/diff/gr-diff-builder/gr-diff-builder-image.ts @@ -10,6 +10,8 @@ import '../gr-diff-image-viewer/gr-image-viewer'; import {html, LitElement, nothing} from 'lit'; import {customElement, property, query, state} from 'lit/decorators.js'; import {GrDiffBuilder} from './gr-diff-builder'; +import {createElementDiff} from '../gr-diff/gr-diff-utils'; +import {GrDiffGroup} from '../gr-diff/gr-diff-group'; // MIME types for images we allow showing. Do not include SVG, it can contain // arbitrary JavaScript. @@ -28,6 +30,13 @@ export class GrDiffBuilderImage extends GrDiffBuilder { super(diff, prefs, outputEl, [], renderPrefs); } + override buildSectionElement(group: GrDiffGroup): HTMLElement { + const section = createElementDiff('tbody'); + // Do not create a diff row for 'LOST'. + if (group.lines[0].beforeNumber !== 'FILE') return section; + return super.buildSectionElement(group); + } + public renderImageDiff() { const imageDiff = this.useNewImageDiffUi ? this.createImageDiffNew() |