Skip to content

Commit 7554b75

Browse files
authored
Flyout - Element prop name update (#2597)
1 parent dd6c35a commit 7554b75

File tree

1 file changed

+13
-11
lines changed
  • packages/components/src/components/hds/flyout

1 file changed

+13
-11
lines changed

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

+13-11
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export interface HdsFlyoutSignature {
5959

6060
export default class HdsFlyout extends Component<HdsFlyoutSignature> {
6161
@tracked private _isOpen = false;
62-
private _element!: HTMLDialogElement;
62+
// TODO: make this property private; currently blocked by our consumers relying on it despite not being part of the public API: https://github.com/hashicorp/cloud-ui/blob/main/engines/waypoint/addon/components/preview-pane.ts#L15
63+
// private _element!: HTMLDialogElement;
64+
element!: HTMLDialogElement;
6365
private _body!: HTMLElement;
6466
private _bodyInitialOverflowValue = '';
6567

@@ -116,7 +118,7 @@ export default class HdsFlyout extends Component<HdsFlyoutSignature> {
116118
@action
117119
didInsert(element: HTMLDialogElement): void {
118120
// Store references of `<dialog>` and `<body>` elements
119-
this._element = element;
121+
this.element = element;
120122
this._body = document.body;
121123

122124
if (this._body) {
@@ -126,18 +128,18 @@ export default class HdsFlyout extends Component<HdsFlyoutSignature> {
126128
}
127129

128130
// Register "onClose" callback function to be called when a native 'close' event is dispatched
129-
this._element.addEventListener('close', this.registerOnCloseCallback, true);
131+
this.element.addEventListener('close', this.registerOnCloseCallback, true);
130132

131133
// If the flyout dialog is not already open
132-
if (!this._element.open) {
134+
if (!this.element.open) {
133135
this.open();
134136
}
135137
}
136138

137139
@action
138140
willDestroyNode(): void {
139-
if (this._element) {
140-
this._element.removeEventListener(
141+
if (this.element) {
142+
this.element.removeEventListener(
141143
'close',
142144
this.registerOnCloseCallback,
143145
true
@@ -148,7 +150,7 @@ export default class HdsFlyout extends Component<HdsFlyoutSignature> {
148150
@action
149151
open(): void {
150152
// Make flyout dialog visible using the native `showModal` method
151-
this._element.showModal();
153+
this.element.showModal();
152154
this._isOpen = true;
153155

154156
// Prevent page from scrolling when the dialog is open
@@ -165,17 +167,17 @@ export default class HdsFlyout extends Component<HdsFlyoutSignature> {
165167
// allow ember test helpers to be aware of when the `close` event fires
166168
// when using `click` or other helpers from '@ember/test-helpers'
167169
// Notice: this code will get stripped out in production builds (DEBUG evaluates to `true` in dev/test builds, but `false` in prod builds)
168-
if (this._element.open) {
170+
if (this.element.open) {
169171
const token = waiter.beginAsync();
170172
const listener = () => {
171173
waiter.endAsync(token);
172-
this._element.removeEventListener('close', listener);
174+
this.element.removeEventListener('close', listener);
173175
};
174-
this._element.addEventListener('close', listener);
176+
this.element.addEventListener('close', listener);
175177
}
176178

177179
// Make flyout dialog invisible using the native `close` method
178-
this._element.close();
180+
this.element.close();
179181

180182
// Reset page `overflow` property
181183
if (this._body) {

0 commit comments

Comments
 (0)