@@ -3,7 +3,6 @@ import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
3
3
import { createHigherOrderComponent , compose } from '@wordpress/compose' ;
4
4
import { addFilter } from '@wordpress/hooks' ;
5
5
import clsx from 'clsx' ;
6
- import { isEmpty } from 'lodash' ;
7
6
import { useFormStyle } from '../util/form' ;
8
7
import { withSharedFieldAttributes } from '../util/with-shared-field-attributes' ;
9
8
import JetpackFieldControls from './jetpack-field-controls' ;
@@ -20,7 +19,7 @@ const JetpackField = props => {
20
19
requiredText,
21
20
label,
22
21
setAttributes,
23
- placeholder,
22
+ placeholder = '' ,
24
23
width,
25
24
insertBlocksAfter,
26
25
type,
@@ -31,7 +30,7 @@ const JetpackField = props => {
31
30
const blockProps = useBlockProps ( {
32
31
className : clsx ( 'jetpack-field' , {
33
32
'is-selected' : isSelected ,
34
- 'has-placeholder' : ! isEmpty ( placeholder ) ,
33
+ 'has-placeholder' : placeholder !== '' ,
35
34
} ) ,
36
35
style : blockStyle ,
37
36
} ) ;
@@ -51,8 +50,8 @@ const JetpackField = props => {
51
50
className = "jetpack-field__input"
52
51
onChange = { e => setAttributes ( { placeholder : e . target . value } ) }
53
52
style = { fieldStyle }
54
- type = { type }
55
- value = ""
53
+ type = { isSelected ? 'text' : type }
54
+ value = { isSelected ? placeholder : '' }
56
55
placeholder = { placeholder }
57
56
onClick = { event => type === 'file' && event . preventDefault ( ) }
58
57
onKeyDown = { event => {
@@ -71,7 +70,6 @@ const JetpackField = props => {
71
70
setAttributes = { setAttributes }
72
71
placeholder = { placeholder }
73
72
attributes = { attributes }
74
- hidePlaceholder = { type === 'number' }
75
73
/>
76
74
</ >
77
75
) ;
0 commit comments