Skip to content

Commit 345c550

Browse files
author
shleewhite
committed
fix: use custom modifiers instead of did-insert
1 parent 0e325c6 commit 345c550

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

packages/components/src/components/hds/app-side-nav/index.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{on "transitionend" (fn this.setTransition "end")}}
1111
{{! @glint-expect-error - https://github.com/josemarluedke/ember-focus-trap/issues/86 }}
1212
{{focus-trap isActive=this.shouldTrapFocus}}
13-
{{did-insert this.didInsert}}
13+
{{this._setUpBodyElement}}
1414
>
1515
<h2 class="sr-only" id="hds-app-side-nav-header">Application local navigation</h2>
1616

@@ -27,7 +27,7 @@
2727
/>
2828
{{/if}}
2929

30-
<div class="hds-app-side-nav__wrapper-body" {{did-insert this.didInsertNavWrapperBody}}>
30+
<div class="hds-app-side-nav__wrapper-body" {{this._setUpNavWrapperBody}}>
3131
{{~yield~}}
3232
</div>
3333
</div>

packages/components/src/components/hds/app-side-nav/index.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { tracked } from '@glimmer/tracking';
88
import { action } from '@ember/object';
99
import { registerDestructor } from '@ember/destroyable';
1010
import type Owner from '@ember/owner';
11+
import { modifier } from 'ember-modifier';
1112

1213
import { hdsBreakpoints } from '@hashicorp/design-system-components/utils/hds-breakpoints';
1314

@@ -49,6 +50,17 @@ export default class HdsAppSideNav extends Component<HdsAppSideNavSignature> {
4950
});
5051
}
5152

53+
private _setUpBodyElement = modifier(() => {
54+
this._body = document.body;
55+
// Store the initial `overflow` value of `<body>` so we can reset to it
56+
this._bodyInitialOverflowValue =
57+
this._body.style.getPropertyValue('overflow');
58+
});
59+
60+
private _setUpNavWrapperBody = modifier((element: HTMLElement) => {
61+
this._navWrapperBody = element;
62+
});
63+
5264
addEventListeners(): void {
5365
// eslint-disable-next-line @typescript-eslint/unbound-method
5466
document.addEventListener('keydown', this.escapePress, true);
@@ -183,19 +195,6 @@ export default class HdsAppSideNav extends Component<HdsAppSideNavSignature> {
183195
}
184196
}
185197

186-
@action
187-
didInsert(): void {
188-
this._body = document.body;
189-
// Store the initial `overflow` value of `<body>` so we can reset to it
190-
this._bodyInitialOverflowValue =
191-
this._body.style.getPropertyValue('overflow');
192-
}
193-
194-
@action
195-
didInsertNavWrapperBody(element: HTMLElement): void {
196-
this._navWrapperBody = element;
197-
}
198-
199198
@action
200199
setTransition(phase: string, event: TransitionEvent): void {
201200
// we only want to respond to `width` animation/transitions

0 commit comments

Comments
 (0)