@@ -21,17 +21,19 @@ const DROP_TYPES = ['project-asset-gltf']
2121
2222export default withSdk < Props > (
2323 withContextMenu < WithSdkProps & Props > ( ( { sdk, entity, contextMenuId } ) => {
24- const [ files ] = useFileSystem ( )
24+ const [ files , init ] = useFileSystem ( )
2525 const { handleAction } = useContextMenu ( )
2626 const { GltfContainer } = sdk . components
2727
2828 const hasGltf = useHasComponent ( entity , GltfContainer )
2929 const handleInputValidation = useCallback ( ( { src } : { src : string } ) => isValidInput ( files , src ) , [ files ] )
30- const getInputProps = useComponentInput ( entity , GltfContainer , fromGltf , toGltf , handleInputValidation )
30+ const { getInputProps, isValid } = useComponentInput ( entity , GltfContainer , fromGltf , toGltf , handleInputValidation , [ files ] )
3131
3232 const handleRemove = useCallback ( ( ) => GltfContainer . deleteFrom ( entity ) , [ ] )
33- const handleDrop = useCallback ( ( src : string ) => {
34- GltfContainer . createOrReplace ( entity , { src } )
33+ const handleDrop = useCallback ( async ( src : string ) => {
34+ const { operations } = sdk
35+ operations . updateValue ( GltfContainer , entity , { src } )
36+ await operations . dispatch ( )
3537 } , [ ] )
3638
3739 const [ { isHover } , drop ] = useDrop (
@@ -56,15 +58,17 @@ export default withSdk<Props>(
5658
5759 if ( ! hasGltf ) return null
5860
61+ const inputProps = getInputProps ( 'src' )
62+
5963 return (
6064 < Container label = "Gltf" className = { cx ( 'Gltf' , { hover : isHover } ) } >
6165 < Menu id = { contextMenuId } >
6266 < Item id = "delete" onClick = { handleAction ( handleRemove ) } >
6367 < DeleteIcon /> Delete
6468 </ Item >
6569 </ Menu >
66- < Block label = "Path" ref = { drop } >
67- < TextField type = "text" { ...getInputProps ( 'src' ) } />
70+ < Block label = "Path" ref = { drop } error = { init && ! isValid } >
71+ < TextField type = "text" { ...inputProps } />
6872 </ Block >
6973 </ Container >
7074 )
0 commit comments