@@ -91,6 +91,37 @@ export class FormBaseInput extends PureComponent {
9191 return props . renderValue ( props . value ) ;
9292 }
9393
94+ renderInputComponent ( ) {
95+ const { id, idForError, idForInstructions } = this . props ;
96+
97+ const InputComponent =
98+ this . context ?. styleType === "secondary"
99+ ? Styled . SecondaryInput
100+ : Styled . PrimaryInput ;
101+
102+ return (
103+ < InputComponent
104+ ref = { input => {
105+ this . inputElement = input ;
106+ } }
107+ id = { id }
108+ name = { this . props . name }
109+ disabled = { this . props . isDisabled }
110+ type = { this . props . inputType ?? this . props . type }
111+ placeholder = { this . props . placeholder }
112+ onChange = { this . props . onChange }
113+ onKeyDown = { e => {
114+ if ( this . props . onKeyDown ) this . props . onKeyDown ( e , this . inputElement ) ;
115+ } }
116+ value = { this . renderValue ( this . props ) }
117+ aria-describedby = { `${ idForError || "" } ${ idForInstructions || "" } ` }
118+ autoComplete = { this . props . autoComplete }
119+ defaultValue = { this . props . defaultValue }
120+ required = { this . props . required }
121+ />
122+ ) ;
123+ }
124+
94125 render ( ) {
95126 const {
96127 id,
@@ -107,11 +138,6 @@ export class FormBaseInput extends PureComponent {
107138 } ) ;
108139 const Wrapper = buttons ? Styled . WrapperWithActions : Errorable ;
109140
110- const InputComponent =
111- this . context ?. styleType === "secondary"
112- ? Styled . SecondaryInput
113- : Styled . PrimaryInput ;
114-
115141 return (
116142 < Wrapper
117143 className = { buttons ? undefined : fieldClasses }
@@ -126,26 +152,14 @@ export class FormBaseInput extends PureComponent {
126152 hasInstructions = { isString ( instructions ) }
127153 styleType = { this . context ?. styleType }
128154 />
129- < InputComponent
130- ref = { input => {
131- this . inputElement = input ;
132- } }
133- id = { id }
134- name = { this . props . name }
135- disabled = { this . props . isDisabled }
136- type = { this . props . inputType ?? this . props . type }
137- placeholder = { this . props . placeholder }
138- onChange = { this . props . onChange }
139- onKeyDown = { e => {
140- if ( this . props . onKeyDown )
141- this . props . onKeyDown ( e , this . inputElement ) ;
142- } }
143- value = { this . renderValue ( this . props ) }
144- aria-describedby = { `${ idForError || "" } ${ idForInstructions || "" } ` }
145- autoComplete = { this . props . autoComplete }
146- defaultValue = { this . props . defaultValue }
147- required = { this . props . required }
148- />
155+ { this . props . inputType === "color" ? (
156+ < span className = "ColorInput-wrapper" >
157+ { this . renderInputComponent ( ) }
158+ < span > { this . renderValue ( this . props ) } </ span >
159+ </ span >
160+ ) : (
161+ this . renderInputComponent ( )
162+ ) }
149163 { buttons && this . renderButtons ( buttons ) }
150164 { this . props . instructions && (
151165 < Instructions
0 commit comments