Onboarding: Add error styling and text to country state dropdown (https://github.com/woocommerce/woocommerce-admin/pull/3494)
* Add onBlur prop to select control input * Add controlCLassName prop to SelectControl * Set left position for control help text explicitly
This commit is contained in:
parent
7cc0611902
commit
8707c5c13a
|
@ -179,6 +179,7 @@ export function StoreAddress( props ) {
|
||||||
options={ countryStateOptions }
|
options={ countryStateOptions }
|
||||||
isSearchable
|
isSearchable
|
||||||
{ ...getInputProps( 'countryState' ) }
|
{ ...getInputProps( 'countryState' ) }
|
||||||
|
controlClassName={ getInputProps( 'countryState' ).className }
|
||||||
>
|
>
|
||||||
{ getCountryStateAutofill(
|
{ getCountryStateAutofill(
|
||||||
countryStateOptions,
|
countryStateOptions,
|
||||||
|
|
|
@ -115,6 +115,7 @@
|
||||||
|
|
||||||
.components-base-control__help {
|
.components-base-control__help {
|
||||||
top: 100%;
|
top: 100%;
|
||||||
|
left: $gap-small;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
margin-top: $gap-smallest;
|
margin-top: $gap-smallest;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|
|
@ -51,6 +51,12 @@ class Control extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onBlur() {
|
onBlur() {
|
||||||
|
const { onBlur } = this.props;
|
||||||
|
|
||||||
|
if ( 'function' === typeof onBlur ) {
|
||||||
|
onBlur();
|
||||||
|
}
|
||||||
|
|
||||||
this.setState( { isActive: false } );
|
this.setState( { isActive: false } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +157,7 @@ class Control extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { hasTags, help, inlineTags, instanceId, isSearchable, label, query } = this.props;
|
const { className, hasTags, help, inlineTags, instanceId, isSearchable, label, query } = this.props;
|
||||||
const { isActive } = this.state;
|
const { isActive } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -162,7 +168,7 @@ class Control extends Component {
|
||||||
// for the benefit of sighted users.
|
// for the benefit of sighted users.
|
||||||
/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
|
/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
|
||||||
<div
|
<div
|
||||||
className={ classnames( 'components-base-control', 'woocommerce-select-control__control', {
|
className={ classnames( 'components-base-control', 'woocommerce-select-control__control', className, {
|
||||||
empty: ! query.length,
|
empty: ! query.length,
|
||||||
'is-active': isActive,
|
'is-active': isActive,
|
||||||
'has-tags': inlineTags && hasTags,
|
'has-tags': inlineTags && hasTags,
|
||||||
|
@ -234,6 +240,10 @@ Control.propTypes = {
|
||||||
* ID used for a11y in the listbox.
|
* ID used for a11y in the listbox.
|
||||||
*/
|
*/
|
||||||
listboxId: PropTypes.string,
|
listboxId: PropTypes.string,
|
||||||
|
/**
|
||||||
|
* Function called when the input is blurred.
|
||||||
|
*/
|
||||||
|
onBlur: PropTypes.func,
|
||||||
/**
|
/**
|
||||||
* Function called when selected results change, passed result list.
|
* Function called when selected results change, passed result list.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -242,6 +242,7 @@ export class SelectControl extends Component {
|
||||||
autofill,
|
autofill,
|
||||||
children,
|
children,
|
||||||
className,
|
className,
|
||||||
|
controlClassName,
|
||||||
inlineTags,
|
inlineTags,
|
||||||
instanceId,
|
instanceId,
|
||||||
isSearchable,
|
isSearchable,
|
||||||
|
@ -279,6 +280,7 @@ export class SelectControl extends Component {
|
||||||
{ ...this.props }
|
{ ...this.props }
|
||||||
{ ...this.state }
|
{ ...this.state }
|
||||||
activeId={ activeId }
|
activeId={ activeId }
|
||||||
|
className={ controlClassName }
|
||||||
hasTags={ hasTags }
|
hasTags={ hasTags }
|
||||||
isExpanded={ isExpanded }
|
isExpanded={ isExpanded }
|
||||||
listboxId={ listboxId }
|
listboxId={ listboxId }
|
||||||
|
@ -322,6 +324,10 @@ SelectControl.propTypes = {
|
||||||
* Class name applied to parent div.
|
* Class name applied to parent div.
|
||||||
*/
|
*/
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
|
/**
|
||||||
|
* Class name applied to control wrapper.
|
||||||
|
*/
|
||||||
|
controlClassName: PropTypes.string,
|
||||||
/**
|
/**
|
||||||
* Exclude already selected options from the options list.
|
* Exclude already selected options from the options list.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue