Commit d41a18e 1 parent f61fb88 commit d41a18e Copy full SHA for d41a18e
File tree 1 file changed +10
-4
lines changed
packages/components/src/palette-edit
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { kebabCase } from 'lodash';
7
7
* WordPress dependencies
8
8
*/
9
9
import { useState , useRef , useEffect } from '@wordpress/element' ;
10
- import { __ } from '@wordpress/i18n' ;
10
+ import { __ , sprintf } from '@wordpress/i18n' ;
11
11
import { lineSolid , moreVertical , plus } from '@wordpress/icons' ;
12
12
import { __experimentalUseFocusOutside as useFocusOutside } from '@wordpress/compose' ;
13
13
@@ -64,6 +64,7 @@ function Option( {
64
64
} ) {
65
65
const focusOutsideProps = useFocusOutside ( onStopEditing ) ;
66
66
const value = isGradient ? element . gradient : element . color ;
67
+
67
68
return (
68
69
< PaletteItem
69
70
as = "div"
@@ -240,8 +241,8 @@ export default function PaletteEdit( {
240
241
editingElement &&
241
242
elements [ editingElement ] &&
242
243
! elements [ editingElement ] . slug ;
243
-
244
- const hasElements = elements . length > 0 ;
244
+ const elementsLength = elements . length ;
245
+ const hasElements = elementsLength > 0 ;
245
246
246
247
return (
247
248
< PaletteEditStyles >
@@ -270,13 +271,18 @@ export default function PaletteEdit( {
270
271
: __ ( 'Add color' )
271
272
}
272
273
onClick = { ( ) => {
274
+ const tempOptionName = sprintf (
275
+ /* translators: %s: is a temporary id for a custom color */
276
+ __ ( 'Color %s ' ) ,
277
+ elementsLength + 1
278
+ ) ;
273
279
onChange ( [
274
280
...elements ,
275
281
{
276
282
...( isGradient
277
283
? { gradient : DEFAULT_GRADIENT }
278
284
: { color : '#000' } ) ,
279
- name : '' ,
285
+ name : tempOptionName ,
280
286
slug : '' ,
281
287
} ,
282
288
] ) ;
You can’t perform that action at this time.
0 commit comments