Skip to content

Commit

Permalink
Fix: #309
Browse files Browse the repository at this point in the history
  • Loading branch information
mkocansey committed Aug 11, 2024
1 parent 1858ece commit cfdf99f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion public/js/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class BladewindSelect {
searchInput;
selectItems;
isMultiple;
required;
displayArea;
formInput;
maxSelection;
Expand All @@ -24,10 +25,11 @@ class BladewindSelect {
this.searchInput = `${this.itemsContainer} .bw_search`;
this.selectItems = `${this.itemsContainer} .bw-select-items .bw-select-item`;
this.isMultiple = (dom_el(this.rootElement).getAttribute('data-multiple') === 'true');
this.required = (dom_el(this.rootElement).getAttribute('data-required') === 'true');
this.formInput = `input.bw-${this.name}`;
dom_el(this.displayArea).style.maxWidth = `${(dom_el(this.rootElement).offsetWidth - 40)}px`;
this.maxSelection = -1;
this.canClear = false;
this.canClear = (!this.required && !this.isMultiple);
this.enabled = true;
}

Expand Down
5 changes: 3 additions & 2 deletions resources/views/components/select.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@
}
</style>
<div class="relative bw-select bw-select-{{$input_name}} @if($add_clearing) mb-3 @endif"
data-multiple="{{$multiple}}" data-type="{{ $data !== 'manual' ? 'dynamic' : 'manual'}}"
data-multiple="{{$multiple}}" data-required="{{$required?'true':'false'}}"
data-type="{{ $data !== 'manual' ? 'dynamic' : 'manual'}}"
@if(!empty($filter)) data-filter="{{ $filter}}" @endif
@if($data == 'manual' && $selected_value != '') data-selected-value="{{implode(',',$selected_value)}}" @endif>
<div tabindex="0"
Expand Down Expand Up @@ -237,5 +238,5 @@ class="bw-{{$input_name}} @if($required) required @endif"
bw_{{ $input_name }}.maxSelectable({{$max_selectable}}, '{{ sprintf($max_error_message, $max_selectable) }}');
@endif
@if(!empty($filter)) bw_{{ $input_name }}.filter('{{ $filter }}');
@endif @if(!($required && $multiple == 'false')) bw_{{ $input_name }}.clearable();@endif
@endif @if(!$required && $multiple == 'false') bw_{{ $input_name }}.clearable();@endif
</script>

0 comments on commit cfdf99f

Please sign in to comment.