Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Expand/Collapse events triggered only on state change #33

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/CollapsableItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ export class CollapsableItem {
}

public expand(collapsableEvent: any, data: any, force: boolean): boolean {
// If the item is already expanded return
if (this.isExpanded) {
return false
}

const { options } = this.collapsable
const expandedItem = this.collapsable.getExpanded()

Expand Down Expand Up @@ -223,9 +228,12 @@ export class CollapsableItem {
public collapse(collapsableEvent: any, data: any, force: boolean): boolean {
const { options } = this.collapsable

// If we can't collapse all & we are not promised to open something & there is only one opened box, we can't
// continue
if (!options.collapsableAll && !this.collapsable.promiseOpen && this.collapsable.getExpanded().length < 2) {
// If the item is not expanded, or if we can't collapse all & we are not promised to open something & there is
// only one opened box, we can't continue
if (
!this.isExpanded ||
(!options.collapsableAll && !this.collapsable.promiseOpen && this.collapsable.getExpanded().length < 2)
) {
return false
}

Expand Down
Loading