Skip to content

Commit

Permalink
fix(pci): scroll top at object page init (#9667)
Browse files Browse the repository at this point in the history
ref: DTRSD-94224

Signed-off-by: Quentin Pavy <[email protected]>
  • Loading branch information
qpavy authored Aug 11, 2023
1 parent 4ef1b6b commit 811631e
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/components/ng-ovh-utils/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import tooltipBox from './tooltipBox/tooltipBox';
import triStateCheckbox from './triStateCheckbox/triStateCheckbox';
import wizard from './wizard/wizard';
import wizardForm from './wizardForm/wizardForm';
import scroll from './scroll/scroll';

const moduleName = 'ngOvhUtils';

Expand All @@ -43,6 +44,7 @@ angular.module(moduleName, [
poll,
popover,
price,
scroll,
storage,
tooltipBox,
triStateCheckbox,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default /* @ngInject */ function scrollTopDirective(ScrollService) {
return {
restrict: 'A',
link() {
ScrollService.scrollTop();
},
};
}
36 changes: 36 additions & 0 deletions packages/components/ng-ovh-utils/src/scroll/scroll-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @type service
* @name ovhServices:ScrollService
* @description
* Provide scroll methods
* @example
* # Usage
* <code:js>
* export default class PciStoragesContainersContainerController {
* */ /* @ngInject */ /*
* constructor(ScrollService) {
* this.ScrollService = ScrollService
* }
*
* $onInit() {
* ScrollService.scrollTop();
* };
*};
*
* </code>
*/
export default /* @ngInject */ function scrollService(
$document,
$timeout,
$anchorScroll,
) {
this.scrollTop = function scrollTop() {
$document[0].body.style.setProperty('height', 'auto', 'important');
$document[0].body.style.setProperty('overflow', 'auto');
$anchorScroll();
$timeout(function() {
$document[0].body.style.removeProperty('height');
$document[0].body.style.removeProperty('overflow');
});
};
}
12 changes: 12 additions & 0 deletions packages/components/ng-ovh-utils/src/scroll/scroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import angular from 'angular';
import scrollService from './scroll-service';
import scrollTopDirective from './scroll-directive';

const moduleName = 'ua.scroll';

angular
.module(moduleName, ['ui.router'])
.service('ScrollService', scrollService)
.directive('ovhScrollTop', scrollTopDirective);

export default moduleName;
5 changes: 1 addition & 4 deletions packages/manager/apps/public-cloud/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
data-ng-controller="PublicCloudController as $ctrl"
>
<div class="d-flex w-100 h-100 position-relative">
<div
class="w-100 h-100 position-absolute"
style="top: 0; left: 0;"
>
<div class="w-100 h-100" style="top: 0; left: 0;">
<div class="h-100 w-100" data-ui-view></div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import '@ovh-ux/ui-kit';
import ovhManagerAdvices from '@ovh-ux/manager-advices';
import trustedNic from '@ovh-ux/manager-trusted-nic';

import ngOvhUtils from '@ovh-ux/ng-ovh-utils';
import billing from './billing';
import contacts from './contacts';
import creating from './creating';
Expand Down Expand Up @@ -68,6 +69,7 @@ angular
quotaExceedError,
regions,
privateRegistry,
ngOvhUtils,
'oui',
'ovhManagerCore',
'ovh-api-services',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div data-ui-view>
<div data-ui-view ovh-scroll-top>
<oui-header
heading="{{ :: $ctrl.container.name }}"
data-ng-if="$ctrl.archive"
Expand Down

0 comments on commit 811631e

Please sign in to comment.