Fix diff mode selector initial state
When gr-diff-view attaches, it may need the user's preferences in order
to set the diff mode selector to the correct state.
In the course of testing this change, I realized that an overriding
diff mode selection wasn't sticking across pages, especially when moving
back and forth in history. Modified gr-change-view to also update the
diff mode from the user's preferences when it notices a different change
is being loaded.
Bug: Issue 4434
Change-Id: Id2041b55bf66d7de66f74d7765ed0db717caeebf
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 7e67ac0..4f965dc 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
@@ -334,6 +334,12 @@
_resetFileListViewState: function() {
this.set('viewState.selectedFileIndex', 0);
+ if (!!this.viewState.changeNum &&
+ this.viewState.changeNum !== this._changeNum) {
+ // Reset the diff mode to null when navigating from one change to
+ // another, so that the user's preference is restored.
+ this.set('viewState.diffMode', null);
+ }
this.set('viewState.changeNum', this._changeNum);
this.set('viewState.patchRange', this._patchRange);
},