Add autoscroll to widget after changing pages (Z#23135651) (#3698)

* Add autoscroll to widget after changing pages

* revert add autoscroll to widget

* add watcher on root.view

* check if scrollIntoView is necessary

---------

Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
Raphael Michel
2023-11-09 10:05:02 +01:00
committed by GitHub
parent 4ff07d12a6
commit 5d28e5a959

View File

@@ -2005,7 +2005,19 @@ var create_widget = function (element) {
observer.observe(this.$el, observerOptions);
},
computed: shared_root_computed,
methods: shared_root_methods
methods: shared_root_methods,
watch: {
'view': function (newValue, oldValue) {
if (oldValue) {
// always make sure the widget is scrolled to the top
// as we only check top, we do not need to wait for a redraw
var rect = this.$el.getBoundingClientRect();
if (rect.top < 0) {
this.$el.scrollIntoView();
}
}
}
}
});
create_overlay(app);
return app;