From d463e226bc9f0a782deebe828f807a5bb8a7bcc2 Mon Sep 17 00:00:00 2001 From: Tao Zhou Date: Mon, 24 Feb 2020 15:07:07 +0100 Subject: [PATCH] Fix `_selectedRevision` for edit patchset Change-Id: I1b415cea3e58e9d514e7c21e4982bf100f48cf1e --- .../change/gr-change-view/gr-change-view.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js index a90fe460c3..1622ebde63 100644 --- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js +++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js @@ -1442,8 +1442,14 @@ } else { this._selectedRevision = Object.values(this._change.revisions).find( - revision => revision._number === - parseInt(this._patchRange.patchNum, 10)); + revision => { + // edit patchset is a special one + const thePatchNum = this._patchRange.patchNum; + if (thePatchNum === 'edit') { + return revision._number === thePatchNum; + } + return revision._number === parseInt(thePatchNum, 10); + }); } }); } @@ -1935,8 +1941,12 @@ if (!this._selectedRevision) { return; } - // If patchNumStr is"edit", then patchNum is undefined hence an OR - const patchNum = parseInt(patchNumStr, 10) || patchNumStr; + + let patchNum = parseInt(patchNumStr, 10); + if (patchNumStr === 'edit') { + patchNum = patchNumStr; + } + if (patchNum === this._selectedRevision._number) { return; }