Skip to content
Merged
Prev Previous commit
Next Next commit
Revert changes to form-input/edit.js
  • Loading branch information
t-hamano committed Jul 26, 2024
commit d47840d9a6e77bf76116e51d5be5bc58603ab8c4
48 changes: 13 additions & 35 deletions packages/block-library/src/form-input/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,32 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
ref.current.focus();
}

// Note: radio inputs aren't implemented yet.
const isCheckboxOrRadio = type === 'checkbox' || type === 'radio';

const controls = (
<>
{ 'hidden' !== type && (
<InspectorControls>
<PanelBody title={ __( 'Settings' ) }>
{ 'checkbox' !== type && (
<CheckboxControl
__nextHasNoMarginBottom
label={ __( 'Inline label' ) }
checked={ inlineLabel }
onChange={ ( newVal ) => {
setAttributes( {
inlineLabel: newVal,
} );
} }
__nextHasNoMarginBottom
/>
) }
<CheckboxControl
__nextHasNoMarginBottom
label={ __( 'Required' ) }
checked={ required }
onChange={ ( newVal ) => {
setAttributes( {
required: newVal,
} );
} }
__nextHasNoMarginBottom
/>
</PanelBody>
</InspectorControls>
Expand Down Expand Up @@ -112,21 +109,17 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
'is-label-inline': inlineLabel || 'checkbox' === type,
} ) }
>
{ ! isCheckboxOrRadio && (
<RichText
tagName="span"
className="wp-block-form-input__label-content"
value={ label }
onChange={ ( newLabel ) =>
setAttributes( { label: newLabel } )
}
aria-label={
label ? __( 'Label' ) : __( 'Empty label' )
}
data-empty={ label ? false : true }
placeholder={ __( 'Type the label for this input' ) }
/>
) }
<RichText
tagName="span"
className="wp-block-form-input__label-content"
value={ label }
onChange={ ( newLabel ) =>
setAttributes( { label: newLabel } )
}
aria-label={ label ? __( 'Label' ) : __( 'Empty label' ) }
data-empty={ label ? false : true }
placeholder={ __( 'Type the label for this input' ) }
/>
<TagName
type={ 'textarea' === type ? undefined : type }
className={ clsx(
Expand All @@ -152,21 +145,6 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
...colorProps.style,
} }
/>
{ isCheckboxOrRadio && (
<RichText
tagName="span"
className="wp-block-form-input__label-content"
value={ label }
onChange={ ( newLabel ) =>
setAttributes( { label: newLabel } )
}
aria-label={
label ? __( 'Label' ) : __( 'Empty label' )
}
data-empty={ label ? false : true }
placeholder={ __( 'Type the label for this input' ) }
/>
) }
</span>
</div>
);
Expand Down