@@ -61,6 +61,11 @@ const SwitchWrapper = styled.div<{ disabled: boolean }>`
6161 ` } ;
6262` ;
6363
64+ const Wrapper = styled . div `
65+ background: transparent !important;
66+ padding: 0 8px;
67+ `
68+
6469const childrenMap = {
6570 value : booleanExposingStateControl ( "value" ) ,
6671 switchState : BoolCodeControl ,
@@ -80,18 +85,16 @@ export const SwitchComp = (function () {
8085 const value = props . changeValue ?? getBaseValue ( props , dispatch ) ;
8186 const CheckBoxComp = ( ) => {
8287 return (
83- < SwitchWrapper disabled = { props . disabled } >
84- < Switch
85- checked = { props . value . value || true }
86- disabled = { props . disabled }
87- ref = { props . viewRef }
88- onChange = { ( checked ) => {
89- props . value . onChange ( checked ) ;
90- props . onEvent ( "change" ) ;
91- props . onEvent ( checked ? "true" : "false" ) ;
92- } }
93- />
94- </ SwitchWrapper >
88+ < Switch
89+ checked = { value }
90+ disabled = { props . disabled || true }
91+ ref = { props . viewRef }
92+ onChange = { ( checked ) => {
93+ props . value . onChange ( checked ) ;
94+ props . onEvent ( "change" ) ;
95+ props . onEvent ( checked ? "true" : "false" ) ;
96+ } }
97+ />
9598 ) ;
9699 } ;
97100 return < CheckBoxComp /> ;
@@ -101,15 +104,22 @@ export const SwitchComp = (function () {
101104 )
102105 . setEditViewFn ( ( props ) => {
103106 return (
104- < Switch
105- checked = { props . value }
106- disabled = { false }
107- onChange = { ( checked ) => {
108- props . onChange ( checked ) ;
109- // props.onEvent("change");
110- // props.onEvent(checked ? "true" : "false");
107+ < Wrapper
108+ onBlur = { ( e ) => {
109+ if ( ! e . currentTarget ?. contains ( e . relatedTarget ) ) {
110+ props . onChangeEnd ( ) ;
111+ }
111112 } }
112- />
113+ >
114+ < Switch
115+ defaultChecked = { props . value }
116+ disabled = { false }
117+ onChange = { ( checked ) => {
118+ props . onChange ( checked ) ;
119+ } }
120+ />
121+
122+ </ Wrapper >
113123 ) ;
114124 } )
115125 . setPropertyViewFn ( ( children ) => {
0 commit comments