Skip to content

Commit

Permalink
refactor(combobox): onToggleOpenCloseComponent replaces connect log…
Browse files Browse the repository at this point in the history
…ic (#7361)

**Related Issue:** #6018

## Summary
Use the new `onToggleOpenCloseComponent` pattern to replace both
`connectOpenCloseComponent` and `disconnectOpenCloseComponent` on
`combobox`. This new pattern is intended to simplify the overall
eventing logic.
  • Loading branch information
Elijbet committed Jul 24, 2023
1 parent 45e7773 commit cc592e6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/calcite-components/src/components/combobox/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ import {
} from "../../utils/loadable";
import { connectLocalized, disconnectLocalized } from "../../utils/locale";
import { createObserver } from "../../utils/observers";
import {
connectOpenCloseComponent,
disconnectOpenCloseComponent,
OpenCloseComponent,
} from "../../utils/openCloseComponent";
import { onToggleOpenCloseComponent, OpenCloseComponent } from "../../utils/openCloseComponent";
import {
connectMessages,
disconnectMessages,
Expand Down Expand Up @@ -127,6 +123,8 @@ export class Combobox

@Watch("open")
openHandler(): void {
onToggleOpenCloseComponent(this);

if (this.disabled) {
this.open = false;
return;
Expand Down Expand Up @@ -401,11 +399,11 @@ export class Combobox
this.mutationObserver?.observe(this.el, { childList: true, subtree: true });
connectLabel(this);
connectForm(this);
connectOpenCloseComponent(this);
this.setFilteredPlacements();
this.reposition(true);
if (this.open) {
this.openHandler();
onToggleOpenCloseComponent(this);
}
}

Expand Down Expand Up @@ -437,7 +435,6 @@ export class Combobox
disconnectLabel(this);
disconnectForm(this);
disconnectFloatingUI(this, this.referenceEl, this.floatingEl);
disconnectOpenCloseComponent(this);
disconnectLocalized(this);
disconnectMessages(this);
}
Expand Down Expand Up @@ -783,7 +780,6 @@ export class Combobox
this.resizeObserver.observe(el);
this.listContainerEl = el;
this.transitionEl = el;
connectOpenCloseComponent(this);
};

setReferenceEl = (el: HTMLDivElement): void => {
Expand Down

0 comments on commit cc592e6

Please sign in to comment.