mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 06:21:23 +00:00
perf: defer autoUpdate until menu is open to fix slow profile icon rendering
autoUpdate from @floating-ui/dom was being started in connect(), causing immediate layout/size calculations for every menu instance on page load even while closed. Moved autoUpdate to only run when the menu is open, and stop when closed/toggled off. https://claude.ai/code/session_01FkTsyLvEod4qN6T5dNidkL
This commit is contained in:
@@ -24,7 +24,6 @@ export default class extends Controller {
|
||||
this.show = this.showValue;
|
||||
this.boundUpdate = this.update.bind(this);
|
||||
this.addEventListeners();
|
||||
this.startAutoUpdate();
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
@@ -66,14 +65,18 @@ export default class extends Controller {
|
||||
this.show = !this.show;
|
||||
this.contentTarget.classList.toggle("hidden", !this.show);
|
||||
if (this.show) {
|
||||
this.startAutoUpdate();
|
||||
this.update();
|
||||
this.focusFirstElement();
|
||||
} else {
|
||||
this.stopAutoUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
close() {
|
||||
this.show = false;
|
||||
this.contentTarget.classList.add("hidden");
|
||||
this.stopAutoUpdate();
|
||||
}
|
||||
|
||||
focusFirstElement() {
|
||||
|
||||
Reference in New Issue
Block a user