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

[5.x] Fix ButtonGroup not showing active state if value are numbers #10916

Merged
merged 11 commits into from
Dec 16, 2024
4 changes: 2 additions & 2 deletions resources/js/components/fieldtypes/ButtonGroupFieldtype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
ref="button"
type="button"
:name="name"
@click="updateSelectedOption($event.target.value)"
@click="updateSelectedOption(option.value)"
:value="option.value"
:disabled="isReadOnly"
:class="{'active': value === option.value}"
:class="{'active': value == option.value}"
v-text="option.label || option.value"
/>
</div>
Expand Down
14 changes: 11 additions & 3 deletions tests/Fieldtypes/HasSelectOptionsTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,46 @@ public function it_preloads_options($options, $expected)
$field = $this->field(['options' => $options]);

$this->assertArrayHasKey('options', $preloaded = $field->preload());
$this->assertEquals($expected, $preloaded['options']);
$this->assertSame($expected, $preloaded['options']);
}

public static function optionsProvider()
{
return [
'list' => [
['one', 'two', 'three'],
['one', 'two', 'three', 50, '100'],
[
['value' => 'one', 'label' => 'one'],
['value' => 'two', 'label' => 'two'],
['value' => 'three', 'label' => 'three'],
['value' => 50, 'label' => 50],
['value' => '100', 'label' => '100'],
],
],
'associative' => [
['one' => 'One', 'two' => 'Two', 'three' => 'Three'],
['one' => 'One', 'two' => 'Two', 'three' => 'Three', 50 => '50', '100' => 100],
[
['value' => 'one', 'label' => 'One'],
['value' => 'two', 'label' => 'Two'],
['value' => 'three', 'label' => 'Three'],
['value' => 50, 'label' => '50'],
['value' => 100, 'label' => 100],
],
],
'multidimensional' => [
[
['key' => 'one', 'value' => 'One'],
['key' => 'two', 'value' => 'Two'],
['key' => 'three', 'value' => 'Three'],
['key' => 50, 'value' => 50],
['key' => '100', 'value' => 100],
],
[
['value' => 'one', 'label' => 'One'],
['value' => 'two', 'label' => 'Two'],
['value' => 'three', 'label' => 'Three'],
['value' => 50, 'label' => 50],
['value' => '100', 'label' => 100],
],
],
];
Expand Down
Loading