@@ -19,6 +19,7 @@ import {
1919} from '~stackable/components'
2020import {
2121 useBlockAttributesContext ,
22+ useBlockColorSchemes ,
2223 useBlockLayoutDefaults ,
2324 useBlockSetAttributesContext ,
2425} from '~stackable/hooks'
@@ -28,7 +29,6 @@ import {
2829 */
2930import { __ } from '@wordpress/i18n'
3031import { memo } from '@wordpress/element'
31- import { useSelect } from '@wordpress/data'
3232
3333export const Edit = memo ( props => {
3434 const {
@@ -37,17 +37,9 @@ export const Edit = memo( props => {
3737 backgroundMediaAllowVideo,
3838 } = props
3939
40- const { COLOR_SCHEME_OPTIONS , backgroundModeColorScheme } = useSelect ( select => {
41- const { colorSchemes, backgroundModeColorScheme } = select ( 'stackable/global-color-schemes' ) . getSettings ( )
42- const COLOR_SCHEME_OPTIONS = colorSchemes ?. map ( scheme => ( {
43- label : scheme . name ,
44- value : scheme . key ,
45- } ) )
46- return {
47- COLOR_SCHEME_OPTIONS ,
48- backgroundModeColorScheme,
49- }
50- } )
40+ const {
41+ COLOR_SCHEME_OPTIONS , getScheme, backgroundModeColorScheme,
42+ } = useBlockColorSchemes ( )
5143
5244 const backgroundColorScheme = useBlockAttributesContext ( attributes => attributes . backgroundColorScheme )
5345 const hasBackground = useBlockAttributesContext ( attributes => attributes . hasBackground )
@@ -93,9 +85,9 @@ export const Edit = memo( props => {
9385 >
9486 < AdvancedSelectControl
9587 label = { __ ( 'Color Scheme' , i18n ) }
96- value = { backgroundColorScheme || backgroundModeColorScheme }
88+ value = { getScheme ( backgroundColorScheme , 'background' ) || backgroundModeColorScheme }
9789 options = { COLOR_SCHEME_OPTIONS }
98- onChange = { backgroundColorScheme => ( { backgroundColorScheme } ) }
90+ onChange = { backgroundColorScheme => setAttributes ( { backgroundColorScheme : backgroundColorScheme === backgroundModeColorScheme ? '' : backgroundColorScheme } ) }
9991 default = { backgroundModeColorScheme }
10092 />
10193 < BackgroundControls
0 commit comments