Skip to content

Commit

Permalink
Fix event for when it starts open
Browse files Browse the repository at this point in the history
  • Loading branch information
rugoncalves committed Jan 6, 2025
1 parent f518d87 commit 59d0620
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/scripts/OSFramework/OSUI/Pattern/Sidebar/Sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,19 @@ namespace OSFramework.OSUI.Patterns.Sidebar {
//let's only change the property and trigger the OS event IF the pattern is already built.
this._isOpen = true;
this._triggerOnToggleEvent();
}

if (this._clickOutsideToClose || (this.configs.HasOverlay && this._clickOutsideToClose === undefined)) {
Event.DOMEvents.Listeners.GlobalListenerManager.Instance.addHandler(
Event.DOMEvents.Listeners.Type.BodyOnMouseDown,
this._eventOverlayMouseDown
);
Event.DOMEvents.Listeners.GlobalListenerManager.Instance.addHandler(
Event.DOMEvents.Listeners.Type.BodyOnClick,
this._eventOverlayClick
);
}
// The sidebar can be set to be open, when created (start open). And in this case, the events
// should be added, even if the pattern is not built yet.
if (this._clickOutsideToClose || (this.configs.HasOverlay && this._clickOutsideToClose === undefined)) {
Event.DOMEvents.Listeners.GlobalListenerManager.Instance.addHandler(
Event.DOMEvents.Listeners.Type.BodyOnMouseDown,
this._eventOverlayMouseDown
);
Event.DOMEvents.Listeners.GlobalListenerManager.Instance.addHandler(
Event.DOMEvents.Listeners.Type.BodyOnClick,
this._eventOverlayClick
);
}

this.selfElement.focus();
Expand Down

0 comments on commit 59d0620

Please sign in to comment.