File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
packages/components/src/palette-edit Expand file tree Collapse file tree 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';
77 * WordPress dependencies
88 */
99import { useState , useRef , useEffect } from '@wordpress/element' ;
10- import { __ } from '@wordpress/i18n' ;
10+ import { __ , sprintf } from '@wordpress/i18n' ;
1111import { lineSolid , moreVertical , plus } from '@wordpress/icons' ;
1212import { __experimentalUseFocusOutside as useFocusOutside } from '@wordpress/compose' ;
1313
@@ -64,6 +64,7 @@ function Option( {
6464} ) {
6565 const focusOutsideProps = useFocusOutside ( onStopEditing ) ;
6666 const value = isGradient ? element . gradient : element . color ;
67+
6768 return (
6869 < PaletteItem
6970 as = "div"
@@ -240,8 +241,8 @@ export default function PaletteEdit( {
240241 editingElement &&
241242 elements [ editingElement ] &&
242243 ! elements [ editingElement ] . slug ;
243-
244- const hasElements = elements . length > 0 ;
244+ const elementsLength = elements . length ;
245+ const hasElements = elementsLength > 0 ;
245246
246247 return (
247248 < PaletteEditStyles >
@@ -270,13 +271,18 @@ export default function PaletteEdit( {
270271 : __ ( 'Add color' )
271272 }
272273 onClick = { ( ) => {
274+ const tempOptionName = sprintf (
275+ /* translators: %s: is a temporary id for a custom color */
276+ __ ( 'Color %s ' ) ,
277+ elementsLength + 1
278+ ) ;
273279 onChange ( [
274280 ...elements ,
275281 {
276282 ...( isGradient
277283 ? { gradient : DEFAULT_GRADIENT }
278284 : { color : '#000' } ) ,
279- name : '' ,
285+ name : tempOptionName ,
280286 slug : '' ,
281287 } ,
282288 ] ) ;
You can’t perform that action at this time.
0 commit comments