Skip to content

Commit

Permalink
Merge pull request #147 from unicef/feature/update-react-select
Browse files Browse the repository at this point in the history
Fix required attribute in USelectPicker
  • Loading branch information
vinuganesan authored Jan 12, 2024
2 parents 12f6b3c + 77ef633 commit 566ea65
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unicef/material-ui",
"version": "0.12.1",
"version": "0.12.2",
"description": "UNICEF theme and components of material-ui for react",
"main": "index.js",
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default function ActiveKeyboardDatePicker(props) {
showLabelHelp,
InputLabelHelpProps,
label,
KeyboardButtonProps,
...others
} = props

Expand Down Expand Up @@ -113,6 +114,7 @@ export default function ActiveKeyboardDatePicker(props) {
}}
readOnly={readOnly}
KeyboardButtonProps={{
...KeyboardButtonProps,
classes: {
root: `${!interactiveMode && !readOnly ? '' : hideIcon}`,
},
Expand Down Expand Up @@ -170,11 +172,14 @@ ActiveKeyboardDatePicker.propTypes = {
showLabelHelp: PropTypes.bool,
/** Props applied to the input label help element. E.g InputLabelHelpProps={{type:'link', label:'Help', link:'unicef.github.io', icon, tooltipTitle: 'Tooltip title', tooltipPlacement: 'bottom}} */
InputLabelHelpProps: PropTypes.object,
/** Keyboard button props */
KeyboardButtonProps: PropTypes.object,
}

ActiveKeyboardDatePicker.defaultProps = {
inputVariant: 'outlined',
autoOk: true,
variant: 'inline',
format: 'dd/MM/yyyy',
KeyboardButtonProps: {},
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default function ActiveKeyboardDateTimePicker(props) {
showLabelHelp,
InputLabelHelpProps,
label,
KeyboardButtonProps,
...others
} = props

Expand Down Expand Up @@ -112,6 +113,7 @@ export default function ActiveKeyboardDateTimePicker(props) {
}}
readOnly={readOnly}
KeyboardButtonProps={{
...KeyboardButtonProps,
classes: {
root: `${!interactiveMode && !readOnly ? '' : hideIcon}`,
},
Expand Down Expand Up @@ -169,11 +171,14 @@ ActiveKeyboardDateTimePicker.propTypes = {
showLabelHelp: PropTypes.bool,
/** Props applied to the input label help element. E.g InputLabelHelpProps={{type:'link', label:'Help', link:'unicef.github.io', icon, tooltipTitle: 'Tooltip title', tooltipPlacement: 'bottom}} */
InputLabelHelpProps: PropTypes.object,
/** Keyboard button props */
KeyboardButtonProps: PropTypes.object,
}

ActiveKeyboardDateTimePicker.defaultProps = {
inputVariant: 'outlined',
autoOk: true,
variant: 'inline',
format: 'dd/MM/yyyy hh:mm a',
KeyboardButtonProps: {},
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export default function ActiveKeyboardTimePicker(props) {
showLabelHelp,
InputLabelHelpProps,
label,
KeyboardButtonProps,
...others
} = props

Expand Down Expand Up @@ -109,6 +110,7 @@ export default function ActiveKeyboardTimePicker(props) {
}}
readOnly={readOnly}
KeyboardButtonProps={{
...KeyboardButtonProps,
classes: {
root: `${!interactiveMode && !readOnly ? '' : hideIcon}`,
},
Expand Down Expand Up @@ -162,10 +164,13 @@ ActiveKeyboardTimePicker.propTypes = {
showLabelHelp: PropTypes.bool,
/** Props applied to the input label help element. E.g InputLabelHelpProps={{type:'link', label:'Help', link:'unicef.github.io', icon, tooltipTitle: 'Tooltip title', tooltipPlacement: 'bottom}} */
InputLabelHelpProps: PropTypes.object,
/** Keyboard button props */
KeyboardButtonProps: PropTypes.object,
}

ActiveKeyboardTimePicker.defaultProps = {
inputVariant: 'outlined',
autoOk: true,
variant: 'inline',
KeyboardButtonProps: {},
}
10 changes: 9 additions & 1 deletion src/components/USelectPicker/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ export default function Input(props) {
: undefined
}

return <components.Input {...props} aria-describedby={describedBy} />
return (
<components.Input
{...props}
aria-describedby={describedBy}
required={
(props && props.selectProps && props.selectProps.required) || undefined
}
/>
)
}

Input.propTypes = {
Expand Down
9 changes: 8 additions & 1 deletion src/components/USelectPicker/InputComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import React from 'react'
import PropTypes from 'prop-types'

export default function InputComponent({ inputRef, ...props }) {
return <div ref={inputRef} {...props} />
return (
<div
ref={inputRef}
{...props}
required={undefined} // Remove required from div element
aria-invalid={undefined} // Remove aria-invalid from div element
/>
)
}

InputComponent.propTypes = {
Expand Down

0 comments on commit 566ea65

Please sign in to comment.