Fix switch between modes and scrolling on adjust

The templateFolderForm JS was setting the mode to
'dialog' but not back when the state was changed
back to a normal sticky element. This caused
adjustments and scrolling when no adjustment
needed to be accommodated.

There were also problems with adjustForResize. It
was manipulating the same flag that resizing the
window did and returned a value never used.
This commit is contained in:
Tom Byers
2019-01-30 19:12:14 +00:00
parent 707c426b9a
commit c89ad9635b
2 changed files with 17 additions and 12 deletions

View File

@@ -139,6 +139,8 @@
};
this.render = function() {
var mode = 'default';
// detach everything, unless they are the currentState
this.states.forEach(
state => (state.key === this.currentState ? this.$stickyBottom.append(state.$el) : state.$el.detach())
@@ -146,8 +148,9 @@
// use dialog mode for states which contain more than one form control
if (['move-to-existing-folder', 'add-new-template'].includes(this.currentState)) {
GOVUK.stickAtBottomWhenScrolling.setMode('dialog');
mode = 'dialog';
}
GOVUK.stickAtBottomWhenScrolling.setMode(mode);
// make sticky JS recalculate its cache of the element's position
GOVUK.stickAtBottomWhenScrolling.recalculate();
};