Skip to content

Commit 73009f0

Browse files
arvsrnBrendonovich
andauthored
feat(app): update arrow buttons in review tab top bar (#39469)
Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com>
1 parent f720490 commit 73009f0

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

packages/session-ui/src/v2/components/session-review-v2.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,13 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
165165
}
166166

167167
const prev = () => {
168-
return props.files[fileIndex() - 1]
168+
if (!canCycle()) return
169+
return props.files[(fileIndex() - 1 + props.files.length) % props.files.length]
169170
}
170171

171172
const next = () => {
172-
return props.files[fileIndex() + 1]
173+
if (!canCycle()) return
174+
return props.files[(fileIndex() + 1) % props.files.length]
173175
}
174176

175177
const canCycle = () => props.files.length > 0
@@ -183,15 +185,15 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
183185
props.onSelectFile(file)
184186
}
185187

186-
// The prev/next tooltips advertise < and >; keep the keys working while the
188+
// Keep the advertised arrow keys working while the
187189
// pane is mounted, but never while typing in an input or comment editor.
188190
makeEventListener(document, "keydown", (event) => {
189191
if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey) return
190-
if (event.key !== "<" && event.key !== ">") return
192+
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return
191193
const target = event.target
192194
if (target instanceof HTMLElement && (target.isContentEditable || target.closest("input, textarea, select"))) return
193195
if (!props.hasDiffs || !canCycle()) return
194-
const file = event.key === "<" ? prev() : next()
196+
const file = event.key === "ArrowLeft" ? prev() : next()
195197
if (!file) return
196198
event.preventDefault()
197199
cycle(file)
@@ -219,7 +221,7 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
219221
value={
220222
<>
221223
{i18n.t("ui.sessionReviewV2.previousFile")}
222-
<KeybindV2 keys={["<"]} variant="neutral" />
224+
<KeybindV2 keys={[""]} variant="neutral" />
223225
</>
224226
}
225227
>
@@ -239,7 +241,7 @@ export function SessionReviewV2(props: SessionReviewV2Props) {
239241
value={
240242
<>
241243
{i18n.t("ui.sessionReviewV2.nextFile")}
242-
<KeybindV2 keys={[">"]} variant="neutral" />
244+
<KeybindV2 keys={[""]} variant="neutral" />
243245
</>
244246
}
245247
>

0 commit comments

Comments
 (0)