Skip to content

Commit

Permalink
add support for disabled selects
Browse files Browse the repository at this point in the history
  • Loading branch information
MattBudz committed Oct 10, 2024
1 parent 0409fdb commit 607080a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/assets/javascripts/shared/combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ class ComboBox {
: this.$comboboxOptions.first();

this.selectOptions($initialOption);
this.$combobox.toggleClass(
'disabled',
!!this.$target.attr('disabled')?.length
);
this.behaviors();
}

Expand Down Expand Up @@ -163,6 +167,11 @@ class ComboBox {
}

that.selectOptions($options);

that.$combobox.toggleClass(
'disabled',
!!$(this).attr('disabled')?.length
);
});
}

Expand Down
9 changes: 9 additions & 0 deletions app/assets/stylesheets/shared/combobox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
--spacing: 0.25rem;
padding: var(--spacing) 2.25rem var(--spacing) var(--spacing);
}

&.disabled {
background-color: $dropdownLinkBackgroundHover;
pointer-events: none;

.unselect-multi-option {
pointer-events: none;
}
}
}

.combobox-menu {
Expand Down

0 comments on commit 607080a

Please sign in to comment.