Skip to content

Commit

Permalink
fix: reinitialize settings tabs for DOM events
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Nov 5, 2024
1 parent 856688f commit 16b9f09
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/gui/src/UI/Settings/UIWindowSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ async function UIWindowSettings(options){
const component = tab.factory();
component.attach(tab_placeholders[i]);
}
if ( tab.reinitialize ) {
tab.reinitialize();
}
if ( tab.dom ) {
tab_placeholders[i].replaceWith(tab.dom);
}
Expand Down
6 changes: 6 additions & 0 deletions src/gui/src/UI/UIElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ export default def(class UIElement extends AdvancedBase {
this.make(this);
}

reinitialize () {
this.root = document.createElement(this.tagName);
this.make(this);
return this.root;
}

async open_as_window (options = {}) {
const placeholder = Placeholder();
console.log('window options?', this.windowOptions);
Expand Down
7 changes: 6 additions & 1 deletion src/gui/src/services/SettingsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ export class SettingsService extends Service {
const ui_element = tab;
tab = {
...ui_element.as(TSettingsTab).get_metadata(),
dom: ui_element.root,
reinitialize () {
ui_element.reinitialize();
},
get dom () {
return ui_element.root;
},
};
}
this.#tabs.push(tab);
Expand Down

0 comments on commit 16b9f09

Please sign in to comment.