Skip to content

Commit 677efb8

Browse files
committed
Move autoUpdate setup to a method
1 parent 9846ec4 commit 677efb8

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/ruby_ui/dropdown_menu/dropdown_menu_controller.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ export default class extends Controller {
2323
connect() {
2424
this.boundHandleKeydown = this.#handleKeydown.bind(this); // Bind the function so we can remove it later
2525
this.selectedIndex = -1;
26-
this.autoUpdateCleanup = autoUpdate(
27-
this.triggerTarget,
28-
this.contentTarget,
29-
this.#computeTooltip.bind(this),
30-
);
26+
27+
this.#setupAutoUpdate();
3128
}
3229

3330
disconnect() {
@@ -36,6 +33,14 @@ export default class extends Controller {
3633
}
3734
}
3835

36+
#setupAutoUpdate() {
37+
this.autoUpdateCleanup = autoUpdate(
38+
this.triggerTarget,
39+
this.contentTarget,
40+
this.#computeTooltip.bind(this),
41+
);
42+
}
43+
3944
#computeTooltip() {
4045
computePosition(this.triggerTarget, this.contentTarget, {
4146
placement: this.optionsValue.placement || "top",

0 commit comments

Comments
 (0)