Skip to content

Commit

Permalink
Fix required attribute in USelectPicker
Browse files Browse the repository at this point in the history
  • Loading branch information
vinu.ganesan committed Jan 12, 2024
1 parent 12f6b3c commit ed7fc35
Show file tree
Hide file tree
Showing 3 changed files with 19 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
11 changes: 10 additions & 1 deletion src/components/USelectPicker/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { components } from 'react-select'
import PropTypes from 'prop-types'

export default function Input(props) {
console.log(props)
let describedBy = props['aria-describedby'] //react-select generated aria-describedby
if (!props.hasValue) {
const customDescribedBy = props.selectProps['aria-describedby'] //custom aria-describedby passed through the props
Expand All @@ -14,7 +15,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 ed7fc35

Please sign in to comment.