Skip to content

Commit 3a2628b

Browse files
Merge pull request #3265 from vuestorefront/v2-release/patch-select
fix: mark placeholder option as selected in react SfSelect (#3263)
2 parents 86bdcde + f2d97a3 commit 3a2628b

File tree

12 files changed

+52
-26
lines changed

12 files changed

+52
-26
lines changed

apps/docs/components/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@nuxtjs/seo": "^2.0.0-rc.10",
2929
"@nuxtjs/tailwindcss": "^6.12.1",
3030
"@storefront-ui/typography": "^2.6.1",
31-
"@storefront-ui/vue": "^2.6.4",
31+
"@storefront-ui/vue": "^2.6.5",
3232
"@tailwindcss/typography": "^0.5.13",
3333
"@vueuse/integrations": "^10.11.0",
3434
"@vueuse/nuxt": "^10.11.0",

packages/sfui/frameworks/nuxt/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# @storefront-ui/nuxt
22

3+
## 2.5.4
4+
5+
### Patch Changes
6+
7+
- Updated dependencies [[`f534058`](https://github.com/vuestorefront/storefront-ui/commit/f534058e4be50f1fb4f3394c6aab525f901b3ee4)]:
8+
- @storefront-ui/vue@2.6.5
9+
310
## 2.5.3
411

512
### Patch Changes

packages/sfui/frameworks/nuxt/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@storefront-ui/nuxt",
3-
"version": "2.5.3",
3+
"version": "2.5.4",
44
"homepage": "https://docs.storefrontui.io/v2/",
55
"installConfig": {
66
"hoistingLimits": "workspaces"

packages/sfui/frameworks/react/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @storefront-ui/react
22

3+
## 2.7.1
4+
5+
### Patch Changes
6+
7+
- [#3263](https://github.com/vuestorefront/storefront-ui/pull/3263) [`f534058`](https://github.com/vuestorefront/storefront-ui/commit/f534058e4be50f1fb4f3394c6aab525f901b3ee4) Thanks [@lsliwaradioluz](https://github.com/lsliwaradioluz)! - [FIXED] Fixed `<SfSelect />` placeholder not appearing initially when no value had been selected.
8+
39
## 2.7.0
410

511
### Minor Changes

packages/sfui/frameworks/react/components/SfSelect/SfSelect.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export default function SfSelect(props: SfSelectProps) {
6464
>
6565
{placeholder && (
6666
<option
67-
disabled
6867
hidden
6968
value=""
7069
className={classNames('bg-neutral-300 text-sm', {

packages/sfui/frameworks/react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@storefront-ui/react",
3-
"version": "2.7.0",
3+
"version": "2.7.1",
44
"license": "MIT",
55
"sideEffects": false,
66
"type": "module",

packages/sfui/frameworks/vue/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @storefront-ui/vue
22

3+
## 2.6.5
4+
5+
### Patch Changes
6+
7+
- [#3263](https://github.com/vuestorefront/storefront-ui/pull/3263) [`f534058`](https://github.com/vuestorefront/storefront-ui/commit/f534058e4be50f1fb4f3394c6aab525f901b3ee4) Thanks [@lsliwaradioluz](https://github.com/lsliwaradioluz)! - [FIXED] Fixed `<SfSelect />` value not updated when no `v-model` is used on the component.
8+
39
## 2.6.4
410

511
### Patch Changes

packages/sfui/frameworks/vue/components/SfInput/SfInput.vue

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<script lang="ts">
2-
export default {
3-
inheritAttrs: false,
4-
};
52
const getSizeClasses = {
63
[SfInputSize.sm]: ' h-[32px]',
74
[SfInputSize.base]: 'h-[40px]',
@@ -14,6 +11,10 @@ import type { PropType, ConcreteComponent } from 'vue';
1411
import { computed, ref, toRefs } from 'vue';
1512
import { SfInputSize, useFocusVisible } from '@storefront-ui/vue';
1613
14+
defineOptions({
15+
inheritAttrs: false,
16+
});
17+
1718
const props = defineProps({
1819
modelValue: {
1920
type: [String, Number],

packages/sfui/frameworks/vue/components/SfScrollable/SfScrollable.vue

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
<script lang="ts">
2-
export default {
3-
inheritAttrs: false,
4-
};
5-
</script>
61
<script lang="ts" setup>
72
import { computed, toRefs, type PropType, type ConcreteComponent, reactive } from 'vue';
83
import {
@@ -21,6 +16,10 @@ import {
2116
type ScrollableOptions,
2217
} from '@storefront-ui/vue';
2318
19+
defineOptions({
20+
inheritAttrs: false,
21+
});
22+
2423
const props = defineProps({
2524
tag: {
2625
type: [String, Object] as PropType<string | ConcreteComponent>,

packages/sfui/frameworks/vue/components/SfSelect/SfSelect.vue

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
<script lang="ts">
2-
export default {
3-
inheritAttrs: false,
4-
};
5-
</script>
61
<script lang="ts" setup>
7-
import { type PropType, computed } from 'vue';
2+
import { type PropType, ref, toRefs, computed } from 'vue';
83
import { SfSelectSize, SfIconExpandMore, useFocusVisible, useDisclosure } from '@storefront-ui/vue';
94
5+
defineOptions({
6+
inheritAttrs: false,
7+
});
8+
109
const props = defineProps({
1110
size: {
1211
type: String as PropType<`${SfSelectSize}`>,
@@ -41,12 +40,22 @@ const emit = defineEmits<{
4140
(event: 'update:modelValue', param: string): void;
4241
}>();
4342
43+
const { modelValue } = toRefs(props);
4444
const { isOpen, close, open } = useDisclosure();
4545
const { isFocusVisible } = useFocusVisible();
4646
47-
const modelProxy = computed({
48-
get: () => props.modelValue,
49-
set: (value: string) => emit('update:modelValue', value),
47+
/*
48+
Internal state has been implemented due to native select's element
49+
value disappearing under certain circumstances. It's important to
50+
keep it here, or to always pass modelValue to the component.
51+
*/
52+
const internalState = ref<string>(modelValue.value);
53+
const selectModel = computed({
54+
get: () => modelValue.value || internalState.value,
55+
set: (value) => {
56+
emit('update:modelValue', value);
57+
internalState.value = value;
58+
},
5059
});
5160
</script>
5261

@@ -62,8 +71,8 @@ const modelProxy = computed({
6271
data-testid="select"
6372
>
6473
<select
74+
v-model="selectModel"
6575
:required="required"
66-
v-model="modelProxy"
6776
:disabled="disabled"
6877
:class="[
6978
'appearance-none disabled:cursor-not-allowed cursor-pointer pl-4 pr-3.5 text-neutral-900 ring-inset focus:ring-primary-700 focus:ring-2 outline-none bg-transparent rounded-md ring-1 ring-neutral-300 hover:ring-primary-700 active:ring-2 active:ring-primary-700 disabled:bg-disabled-100 disabled:text-disabled-900 disabled:ring-disabled-200',
@@ -83,7 +92,6 @@ const modelProxy = computed({
8392
>
8493
<option
8594
v-if="placeholder"
86-
disabled
8795
hidden
8896
class="text-sm bg-neutral-300"
8997
value=""

packages/sfui/frameworks/vue/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@storefront-ui/vue",
3-
"version": "2.6.4",
3+
"version": "2.6.5",
44
"license": "MIT",
55
"sideEffects": false,
66
"exports": {

yarn.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -4195,7 +4195,7 @@ __metadata:
41954195
"@nuxtjs/seo": ^2.0.0-rc.10
41964196
"@nuxtjs/tailwindcss": ^6.12.1
41974197
"@storefront-ui/typography": ^2.6.1
4198-
"@storefront-ui/vue": ^2.6.4
4198+
"@storefront-ui/vue": ^2.6.5
41994199
"@tailwindcss/typography": ^0.5.13
42004200
"@types/node": ^20.12.7
42014201
"@vueuse/integrations": ^10.11.0
@@ -4536,7 +4536,7 @@ __metadata:
45364536
languageName: unknown
45374537
linkType: soft
45384538

4539-
"@storefront-ui/vue@^2.1.0, @storefront-ui/vue@^2.6.4, @storefront-ui/vue@workspace:*, @storefront-ui/vue@workspace:packages/sfui/frameworks/vue":
4539+
"@storefront-ui/vue@^2.1.0, @storefront-ui/vue@^2.6.5, @storefront-ui/vue@workspace:*, @storefront-ui/vue@workspace:packages/sfui/frameworks/vue":
45404540
version: 0.0.0-use.local
45414541
resolution: "@storefront-ui/vue@workspace:packages/sfui/frameworks/vue"
45424542
dependencies:

0 commit comments

Comments
 (0)