From 180eb167077e405efe6428f006f3dc635ddef5a5 Mon Sep 17 00:00:00 2001 From: Becky Siegel Date: Fri, 25 Aug 2017 14:37:13 -0700 Subject: [PATCH] Remove jank in reply dialog Most of the issues in the previous reply dialog related to the fact that: 1) The background content was taller than the viewport. 2) Background scrolling is possible with the dialog open. This change addresses this issue by hiding the bulk of change view content when any change view dialog is opened, and then re-displaying it when the dialog is closed, and letting the dialog take up the entire screen on smaller devices. Bug: Issue 7080, Issue 7070 Change-Id: I5834fc61e8daeee2972e8dca4fad9ac54bf9ebca --- .../gr-change-actions/gr-change-actions.html | 5 +- .../gr-change-actions/gr-change-actions.js | 13 +++ .../gr-change-actions_test.html | 14 +++ .../change/gr-change-view/gr-change-view.html | 15 ++- .../change/gr-change-view/gr-change-view.js | 15 +++ .../gr-change-view/gr-change-view_test.html | 43 +++++++++ .../shared/gr-overlay/gr-overlay.html | 10 ++ .../elements/shared/gr-overlay/gr-overlay.js | 40 ++++++++ .../shared/gr-overlay/gr-overlay_test.html | 91 +++++++++++++++++++ 9 files changed, 241 insertions(+), 5 deletions(-) create mode 100644 polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay_test.html diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html index 18ba163d97..f2ed33acfb 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html @@ -74,9 +74,12 @@ limitations under the License. margin: .5em; text-align: center; } + #mainContent.mobileOverlayOpened { + display: none; + } } -
+
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js index 4691836932..3bccdd87fc 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js @@ -291,6 +291,11 @@ '_actionsChanged(actions.*, revisionActions.*, _additionalActions.*)', ], + listeners: { + 'fullscreen-overlay-opened': '_handleHideBackgroundContent', + 'fullscreen-overlay-closed': '_handleShowBackgroundContent', + }, + ready() { this.$.jsAPI.addElement(this.$.jsAPI.Element.CHANGE_ACTIONS, this); this._loading = false; @@ -939,6 +944,14 @@ this._fireAction('/wip', this.actions.wip, false); }, + _handleHideBackgroundContent() { + this.$.mainContent.classList.add('overlayOpen'); + }, + + _handleShowBackgroundContent() { + this.$.mainContent.classList.remove('overlayOpen'); + }, + /** * Merge sources of change actions into a single ordered array of action * values. diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html index 2390c217a7..55cd9829eb 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html @@ -346,6 +346,20 @@ limitations under the License. }); }); + test('fullscreen-overlay-opened hides content', () => { + sandbox.spy(element, '_handleHideBackgroundContent'); + element.$.overlay.fire('fullscreen-overlay-opened'); + assert.isTrue(element._handleHideBackgroundContent.called); + assert.isTrue(element.$.mainContent.classList.contains('overlayOpen')); + }); + + test('fullscreen-overlay-closed shows content', () => { + sandbox.spy(element, '_handleShowBackgroundContent'); + element.$.overlay.fire('fullscreen-overlay-closed'); + assert.isTrue(element._handleShowBackgroundContent.called); + assert.isFalse(element.$.mainContent.classList.contains('overlayOpen')); + }); + suite('cherry-pick', () => { let fireActionStub; diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html index 0290cb1d2e..700f835a33 100644 --- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html +++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html @@ -326,13 +326,19 @@ limitations under the License. .scrollable { overflow: auto; } + /* Change actions are the only thing thant need to remain visible due + to the fact that they may have the currently visible overlay open. */ + #mainContent.overlayOpen .hideOnMobileOverlay { + display: none; + } }
Loading...
-
+
-
-
@@ -537,6 +543,7 @@ limitations under the License. file-list-increment="{{_numFilesShown}}">
{ + element._loggedIn = true; + element._loading = false; + element._change = { + owner: {_account_id: 1}, + labels: {}, + actions: { + abandon: { + enabled: true, + label: 'Abandon', + method: 'POST', + title: 'Abandon', + }, + }, + }; + sandbox.spy(element, '_handleHideBackgroundContent'); + element.$.replyDialog.fire('fullscreen-overlay-opened'); + assert.isTrue(element._handleHideBackgroundContent.called); + assert.isTrue(element.$.mainContent.classList.contains('overlayOpen')); + assert.equal(getComputedStyle(element.$.actions).display, 'block'); + }); + + test('fullscreen-overlay-closed shows content', () => { + element._loggedIn = true; + element._loading = false; + element._change = { + owner: {_account_id: 1}, + labels: {}, + actions: { + abandon: { + enabled: true, + label: 'Abandon', + method: 'POST', + title: 'Abandon', + }, + }, + }; + sandbox.spy(element, '_handleShowBackgroundContent'); + element.$.replyDialog.fire('fullscreen-overlay-closed'); + assert.isTrue(element._handleShowBackgroundContent.called); + assert.isFalse(element.$.mainContent.classList.contains('overlayOpen')); + }); + test('X should expand all messages', () => { const handleExpand = sandbox.stub(element.$.messageList, 'handleExpandCollapse'); diff --git a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.html b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.html index 419d2f7e4e..1b59d355da 100644 --- a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.html +++ b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.html @@ -25,6 +25,16 @@ limitations under the License. background: #fff; box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px; } + + @media screen and (max-width: 50em) { + :host { + height: 100%; + left: 0; + position: fixed; + right: 0; + top: 0; + } + } diff --git a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js index 8db800464d..ebf2f027c1 100644 --- a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js +++ b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js @@ -16,21 +16,61 @@ const AWAIT_MAX_ITERS = 10; const AWAIT_STEP = 5; + const BREAKPOINT_FULLSCREEN_OVERLAY = '50em'; Polymer({ is: 'gr-overlay', + /** + * Fired when a fullscreen overlay is closed + * + * @event fullscreen-overlay-closed + */ + + /** + * Fired when an overlay is opened in full screen mode + * + * @event fullscreen-overlay-opened + */ + + properties: { + _fullScreenOpen: { + type: Boolean, + value: false, + }, + }, + behaviors: [ Polymer.IronOverlayBehavior, ], + listeners: { + 'iron-overlay-closed': '_close', + 'iron-overlay-cancelled': '_close', + }, + open(...args) { return new Promise(resolve => { Polymer.IronOverlayBehaviorImpl.open.apply(this, args); + if (this._isMobile()) { + this.fire('fullscreen-overlay-opened'); + this._fullScreenOpen = true; + } this._awaitOpen(resolve); }); }, + _isMobile() { + return window.matchMedia(`(max-width: ${BREAKPOINT_FULLSCREEN_OVERLAY})`); + }, + + _close() { + if (this._fullScreenOpen) { + this.fire('fullscreen-overlay-closed'); + this._fullScreenOpen = false; + } + }, + /** * Override the focus stops that iron-overlay-behavior tries to find. */ diff --git a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay_test.html b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay_test.html new file mode 100644 index 0000000000..3f427ca211 --- /dev/null +++ b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay_test.html @@ -0,0 +1,91 @@ + + + + +gr-overlay + + + + + + + + + + + + + + + +