From 11771408e59fd026fe7b68237857d159397d4608 Mon Sep 17 00:00:00 2001 From: Powerplex Date: Fri, 19 Jan 2024 14:16:14 +0100 Subject: [PATCH 1/2] fix(select): forward ref to select items --- package-lock.json | 1 + .../components/select/src/SelectItems.tsx | 89 ++++++++++--------- 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7a935388a..08aaa06c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2399,6 +2399,7 @@ }, "node_modules/@clack/prompts/node_modules/is-unicode-supported": { "version": "1.3.0", + "extraneous": true, "inBundle": true, "license": "MIT", "engines": { diff --git a/packages/components/select/src/SelectItems.tsx b/packages/components/select/src/SelectItems.tsx index 8fe650397..59cc3ed21 100644 --- a/packages/components/select/src/SelectItems.tsx +++ b/packages/components/select/src/SelectItems.tsx @@ -1,5 +1,5 @@ import { cva } from 'class-variance-authority' -import { ChangeEvent, ComponentPropsWithoutRef, PropsWithChildren } from 'react' +import { ChangeEvent, ComponentPropsWithoutRef, forwardRef, PropsWithChildren, Ref } from 'react' import { useSelectContext } from './SelectContext' @@ -35,51 +35,52 @@ export const styles = cva( } ) -export const Items = ({ - children, - className, - ...rest -}: PropsWithChildren>) => { - const { - state, - disabled, - readOnly, - ariaLabel, - fieldLabelId, - isControlled, - onValueChange, - selectedItem, - setValue, - name, - required, - } = useSelectContext() +export const Items = forwardRef( + ( + { children, className, ...rest }: PropsWithChildren>, + ref: Ref + ) => { + const { + state, + disabled, + readOnly, + ariaLabel, + fieldLabelId, + isControlled, + onValueChange, + selectedItem, + setValue, + name, + required, + } = useSelectContext() - const handleChange = (event: ChangeEvent) => { - if (isControlled) { - event.preventDefault() - onValueChange?.(event.target.value) - } else { - setValue(event.target.value) + const handleChange = (event: ChangeEvent) => { + if (isControlled) { + event.preventDefault() + onValueChange?.(event.target.value) + } else { + setValue(event.target.value) + } } - } - return ( - - ) -} + return ( + + ) + } +) -Items.id = 'Items' Items.displayName = 'Select.Items' From d36ad24dd43acf9eebe3ff3627940ef362f92f98 Mon Sep 17 00:00:00 2001 From: spark-ui-bot Date: Tue, 23 Jan 2024 16:53:07 +0000 Subject: [PATCH 2/2] chore: release packages [skip ci] - @spark-ui/select@0.6.3 --- package-lock.json | 3 +-- packages/components/select/CHANGELOG.md | 6 ++++++ packages/components/select/package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 08aaa06c5..44dc2a7ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2399,7 +2399,6 @@ }, "node_modules/@clack/prompts/node_modules/is-unicode-supported": { "version": "1.3.0", - "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -33758,7 +33757,7 @@ }, "packages/components/select": { "name": "@spark-ui/select", - "version": "0.6.2", + "version": "0.6.3", "license": "MIT", "dependencies": { "@spark-ui/icon": "^2.1.1", diff --git a/packages/components/select/CHANGELOG.md b/packages/components/select/CHANGELOG.md index 2a726bcf1..501871085 100644 --- a/packages/components/select/CHANGELOG.md +++ b/packages/components/select/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.6.3](https://github.com/adevinta/spark/compare/@spark-ui/select@0.6.2...@spark-ui/select@0.6.3) (2024-01-23) + +### Bug Fixes + +- **select:** forward ref to select items ([1177140](https://github.com/adevinta/spark/commit/11771408e59fd026fe7b68237857d159397d4608)) + ## [0.6.2](https://github.com/adevinta/spark/compare/@spark-ui/select@0.6.1...@spark-ui/select@0.6.2) (2024-01-16) **Note:** Version bump only for package @spark-ui/select diff --git a/packages/components/select/package.json b/packages/components/select/package.json index 398afdede..22032de19 100644 --- a/packages/components/select/package.json +++ b/packages/components/select/package.json @@ -1,6 +1,6 @@ { "name": "@spark-ui/select", - "version": "0.6.2", + "version": "0.6.3", "description": "Displays a list of options for the user to pick from—triggered by a button.", "publishConfig": { "access": "public"