Skip to content

Commit c2dbfca

Browse files
author
shleewhite
committed
change flyout
1 parent 169a099 commit c2dbfca

File tree

1 file changed

+17
-23
lines changed
  • packages/components/src/components/hds/flyout

1 file changed

+17
-23
lines changed

packages/components/src/components/hds/flyout/index.ts

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import { getElementId } from '../../../utils/hds-get-element-id.ts';
1111
import { buildWaiter } from '@ember/test-waiters';
1212
import type { WithBoundArgs } from '@glint/template';
1313
import { modifier } from 'ember-modifier';
14-
import { registerDestructor } from '@ember/destroyable';
15-
import type Owner from '@ember/owner';
1614

1715
import type { HdsFlyoutSizes } from './types.ts';
1816

@@ -69,26 +67,6 @@ export default class HdsFlyout extends Component<HdsFlyoutSignature> {
6967
private _bodyInitialOverflowValue = '';
7068
private _clickHandler!: (event: MouseEvent) => void;
7169

72-
constructor(owner: Owner, args: HdsFlyoutSignature['Args']) {
73-
super(owner, args);
74-
75-
registerDestructor(this, (): void => {
76-
// if the <dialog> is removed from the dom while open we emulate the close event
77-
if (this._element && this._isOpen) {
78-
this._element.dispatchEvent(new Event('close'));
79-
80-
this._element.removeEventListener(
81-
'close',
82-
// eslint-disable-next-line @typescript-eslint/unbound-method
83-
this.registerOnCloseCallback,
84-
true
85-
);
86-
}
87-
88-
document.removeEventListener('click', this._clickHandler, true);
89-
});
90-
}
91-
9270
/**
9371
* Sets the size of the flyout
9472
* Accepted values: medium, large
@@ -170,7 +148,23 @@ export default class HdsFlyout extends Component<HdsFlyoutSignature> {
170148
capture: true,
171149
passive: false,
172150
});
173-
});
151+
152+
return () => {
153+
// if the <dialog> is removed from the dom while open we emulate the close event
154+
if (this._element && this._isOpen) {
155+
this._element.dispatchEvent(new Event('close'));
156+
157+
this._element.removeEventListener(
158+
'close',
159+
// eslint-disable-next-line @typescript-eslint/unbound-method
160+
this.registerOnCloseCallback,
161+
true
162+
);
163+
}
164+
165+
document.removeEventListener('click', this._clickHandler, true);
166+
}
167+
});
174168

175169
@action
176170
willDestroyNode(): void {

0 commit comments

Comments
 (0)