Skip to content

Commit bcb1eb5

Browse files
authored
feat: Provide GroupContext in TextField (#8415)
1 parent 52a3806 commit bcb1eb5

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

packages/@react-spectrum/s2/src/ColorField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const ColorField = forwardRef(function ColorField(props: ColorFieldProps,
9292
contextualHelp={props.contextualHelp}>
9393
{label}
9494
</FieldLabel>
95-
<FieldGroup role="presentation" isDisabled={isDisabled} isInvalid={isInvalid} size={props.size}>
95+
<FieldGroup size={props.size}>
9696
<Input ref={inputRef} />
9797
{isInvalid && <FieldErrorIcon isDisabled={isDisabled} />}
9898
</FieldGroup>

packages/@react-spectrum/s2/src/NumberField.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ export const NumberField = forwardRef(function NumberField(props: NumberFieldPro
199199
{label}
200200
</FieldLabel>
201201
<FieldGroup
202-
role="presentation"
203-
isDisabled={isDisabled}
204-
isInvalid={isInvalid}
205202
size={size}
206203
styles={style({
207204
...fieldInput(),

packages/@react-spectrum/s2/src/TextField.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ export const TextFieldBase = forwardRef(function TextFieldBase(props: TextFieldP
135135
contextualHelp={props.contextualHelp}>
136136
{label}
137137
</FieldLabel>
138-
{/* TODO: set GroupContext in RAC TextField */}
139-
<FieldGroup role="presentation" isDisabled={isDisabled} isInvalid={isInvalid} size={props.size} styles={fieldGroupCss}>
138+
<FieldGroup size={props.size} styles={fieldGroupCss}>
140139
<InputContext.Consumer>
141140
{ctx => (
142141
<InputContext.Provider value={{...ctx, ref: mergeRefs((ctx as any)?.ref, inputRef)}}>

packages/react-aria-components/src/ColorField.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {ColorChannel, ColorFieldState, ColorSpace, useColorChannelFieldState, us
1515
import {ColorFieldContext} from './RSPContexts';
1616
import {FieldErrorContext} from './FieldError';
1717
import {filterDOMProps} from '@react-aria/utils';
18+
import {GroupContext} from './Group';
1819
import {InputContext} from './Input';
1920
import {InputDOMProps, ValidationResult} from '@react-types/shared';
2021
import {LabelContext} from './Label';
@@ -190,6 +191,7 @@ function useChildren(
190191
[ColorFieldStateContext, state],
191192
[InputContext, {...inputProps, ref: inputRef}],
192193
[LabelContext, {...labelProps, ref: labelRef}],
194+
[GroupContext, {role: 'presentation', isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}],
193195
[TextContext, {
194196
slots: {
195197
description: descriptionProps,

packages/react-aria-components/src/TextField.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {createHideableComponent} from '@react-aria/collections';
1616
import {FieldErrorContext} from './FieldError';
1717
import {filterDOMProps, mergeProps} from '@react-aria/utils';
1818
import {FormContext} from './Form';
19+
import {GroupContext} from './Group';
1920
import {InputContext} from './Input';
2021
import {LabelContext} from './Label';
2122
import React, {createContext, ForwardedRef, useCallback, useRef, useState} from 'react';
@@ -110,6 +111,7 @@ export const TextField = /*#__PURE__*/ createHideableComponent(function TextFiel
110111
[LabelContext, {...labelProps, ref: labelRef}],
111112
[InputContext, {...mergeProps(inputProps, inputContextProps), ref: inputOrTextAreaRef}],
112113
[TextAreaContext, {...inputProps, ref: inputOrTextAreaRef}],
114+
[GroupContext, {role: 'presentation', isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}],
113115
[TextContext, {
114116
slots: {
115117
description: descriptionProps,

0 commit comments

Comments
 (0)