Skip to content

Commit

Permalink
Feat: Handle multiselect filtering url issues (#322)
Browse files Browse the repository at this point in the history
Co-authored-by: Niclas Norin <niclas.norin@helsingborg.se>
  • Loading branch information
NiclasNorin and Niclas Norin authored Aug 25, 2023
1 parent cb800ab commit 58e51fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions source/php/Component/Select/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function init()
//Set general classes
$this->data['classList'][] = $this->getBaseClass($size, true);

if ($multiple) {
if (!empty($multiple)) {
$this->data['isMultiSelect'] = true;
$this->data['classList'][] = $this->getBaseClass('multiselect', true);

Expand All @@ -48,7 +48,7 @@ public function init()
];
}

if(!$multiple) {
if(empty($multiple)) {
$this->data['isMultiSelect'] = false;
$this->data['classList'][] = $this->getBaseClass('singleselect', true);

Expand All @@ -69,16 +69,16 @@ public function init()
$this->data['intersection'] = array_intersect_key($options, $preselectedKeys);
}

if ($name) {
$this->data['selectAttributeList']['name'] = $name;
if (!empty($name)) {
$this->data['selectAttributeList']['name'] = $name . (!empty($multiple) ? '[]' : '');
}

if ($errorMessage) {
if (!empty($errorMessage)) {
$this->data['data-invalid-message'] = $errorMessage;
$this->data['classList'][] = "has-invalid-message";
}

if ($required) {
if (!empty($required)) {
$this->data['selectAttributeList']['required'] = 'required';
$this->data['selectAttributeList']['aria-hidden'] = 'true';
$this->data['selectAttributeList']['data-required'] = '1';
Expand All @@ -93,7 +93,7 @@ public function init()
$this->data['selectAttributeList']
);

$this->data['clearButtonEnabled'] = !$multiple && !$required;
$this->data['clearButtonEnabled'] = empty($multiple) && empty($required);

//Determine if this is selected
$this->data['isSelected'] = function($key, $boolean = true)
Expand Down
8 changes: 4 additions & 4 deletions source/php/Component/Select/select.blade.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<div class="c-field {{ $class }}" {!! $attribute !!}>
@if ($label && $hideLabel)
@if (!empty($label) && !empty($hideLabel))
<label class="u-sr__only" for="select_{{ $id }}">
{{ $label }}
</label>
@endif

@if ($label && !$hideLabel)
@if (!empty($label) && empty($hideLabel))
<label class="c-field__label" for="select_{{ $id }}">
{{ $label }}
@if ($required)
@if (!empty($required))
{{--
Field has aria attribute required, this will be read as required.
Aria hidden in place here, to avoid duplicate notations in screenreader.
Expand All @@ -34,7 +34,7 @@

<select {!! $selectAttributes !!} class="{{ $baseClass }}__select-element" tabindex="-1">

@if ($preselected !== '' && !$isMultiSelect)
@if ($preselected !== '' && empty($isMultiSelect))
<option class="c-select__select-option" value="">{{$placeholder ? $placeholder : ""}}</option>
@endif

Expand Down

0 comments on commit 58e51fd

Please sign in to comment.