Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/ui-date-input/src/DateInput/v2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ import {
} from '@instructure/ui-icons'
import { Popover } from '@instructure/ui-popover/latest'
import { TextInput } from '@instructure/ui-text-input/latest'
import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils'
import {
callRenderProp,
passthroughProps,
useDeterministicId
} from '@instructure/ui-react-utils'
import { getLocale, getTimezone } from '@instructure/ui-i18n'

import type { DateInputProps } from './props'
Expand Down Expand Up @@ -258,14 +262,16 @@ const DateInput = forwardRef(
}

const selectedDate = parseDate(value)[1]
const labelId = useDeterministicId('TextInput-label')()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intentionally TextInput and not DateInput?


return (
<TextInput
{...passthroughProps(rest)}
ref={ref}
inputRef={inputRef}
renderLabel={renderLabel}
aria-label={callRenderProp(renderLabel)}
labelId={labelId}
aria-labelledby={labelId}
onChange={handleInputChange}
onBlur={handleBlur}
isRequired={isRequired}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-text-input/src/TextInput/v2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class TextInput extends Component<TextInputProps> {
super(props)
this._defaultId = props.deterministicId!()
this._messagesId = props.deterministicId!('TextInput-messages')
this._labelId = props.deterministicId!('TextInput-label')
this._labelId = props.labelId ?? props.deterministicId!('TextInput-label')
}

ref: Element | null = null
Expand Down
6 changes: 6 additions & 0 deletions packages/ui-text-input/src/TextInput/v2/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ type TextInputOwnProps = {
*/
id?: string

/**
* id for the label. If empty, it's auto generated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: i'd expand on the explanation a bit further: what id, what label, where, how. doesnt need to be too verbose but i'm not sure if it's obvious why would someone use this

*/
labelId?: string

/**
* the selected value (must be accompanied by an `onChange` prop)
*/
Expand Down Expand Up @@ -228,6 +233,7 @@ const allowedProps: AllowedPropKeys = [
'renderLabel',
'type',
'id',
'labelId',
'value',
'defaultValue',
'interaction',
Expand Down
Loading