@@ -22,12 +22,11 @@ import {
22
22
__experimentalItemGroup as ItemGroup ,
23
23
__experimentalHStack as HStack ,
24
24
__experimentalTruncate as Truncate ,
25
- __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue ,
26
25
} from '@wordpress/components' ;
27
26
import { __ , sprintf } from '@wordpress/i18n' ;
28
27
import { store as noticesStore } from '@wordpress/notices' ;
29
28
import { getFilename } from '@wordpress/url' ;
30
- import { useCallback , Platform , useRef , useState } from '@wordpress/element' ;
29
+ import { useCallback , Platform , useRef } from '@wordpress/element' ;
31
30
import { useDispatch , useSelect } from '@wordpress/data' ;
32
31
import { focus } from '@wordpress/dom' ;
33
32
import { isBlobURL } from '@wordpress/blob' ;
@@ -195,14 +194,8 @@ function BackgroundImageToolsPanelItem( {
195
194
onChange,
196
195
style,
197
196
inheritedValue,
198
- defaultValues,
199
197
themeFileURIs,
200
198
} ) {
201
- const sizeValue =
202
- style ?. background ?. backgroundSize ||
203
- inheritedValue ?. background ?. backgroundSize ||
204
- defaultValues ?. backgroundSize ;
205
-
206
199
const mediaUpload = useSelect (
207
200
( select ) => select ( blockEditorStore ) . getSettings ( ) . mediaUpload ,
208
201
[ ]
@@ -253,18 +246,11 @@ function BackgroundImageToolsPanelItem( {
253
246
}
254
247
255
248
onChange (
256
- setImmutably ( style , [ 'background' ] , {
257
- ...style ?. background ,
258
- backgroundImage : {
259
- url : media . url ,
260
- id : media . id ,
261
- source : 'file' ,
262
- title : media . title || undefined ,
263
- } ,
264
- backgroundSize :
265
- 'auto' === sizeValue || ! sizeValue
266
- ? '50%'
267
- : style ?. background ?. backgroundSize ,
249
+ setImmutably ( style , [ 'background' , 'backgroundImage' ] , {
250
+ url : media . url ,
251
+ id : media . id ,
252
+ source : 'file' ,
253
+ title : media . title || undefined ,
268
254
} )
269
255
) ;
270
256
} ;
@@ -383,8 +369,6 @@ function BackgroundSizeToolsPanelItem( {
383
369
defaultValues,
384
370
themeFileURIs,
385
371
} ) {
386
- const [ lastKnownImageWidth , setLastKnownImageWidth ] =
387
- useState ( undefined ) ;
388
372
const sizeValue =
389
373
style ?. background ?. backgroundSize ||
390
374
inheritedValue ?. background ?. backgroundSize ;
@@ -457,7 +441,6 @@ function BackgroundSizeToolsPanelItem( {
457
441
next === 'auto'
458
442
) {
459
443
nextRepeat = undefined ;
460
- next = lastKnownImageWidth ?? 'auto' ;
461
444
}
462
445
463
446
/*
@@ -466,7 +449,6 @@ function BackgroundSizeToolsPanelItem( {
466
449
*/
467
450
if ( ! next && currentValueForToggle === 'auto' ) {
468
451
next = 'auto' ;
469
- setLastKnownImageWidth ( undefined ) ;
470
452
}
471
453
472
454
onChange (
@@ -476,11 +458,6 @@ function BackgroundSizeToolsPanelItem( {
476
458
backgroundSize : next ,
477
459
} )
478
460
) ;
479
-
480
- const imageWidth = parseQuantityAndUnitFromRawValue ( next ) ;
481
- if ( typeof imageWidth ?. [ 0 ] !== 'undefined' && imageWidth ?. [ 1 ] ) {
482
- setLastKnownImageWidth ( next ) ;
483
- }
484
461
} ;
485
462
486
463
const updateBackgroundPosition = ( next ) => {
@@ -645,7 +622,6 @@ export default function BackgroundPanel( {
645
622
isShownByDefault = { defaultControls . backgroundImage }
646
623
style = { value }
647
624
inheritedValue = { inheritedValue }
648
- defaultValues = { defaultValues }
649
625
themeFileURIs = { themeFileURIs }
650
626
/>
651
627
{ shouldShowBackgroundSizeControls && (
0 commit comments