@sanity/personalization-plugin 2.3.0-growthbook.1 → 2.3.0-growthbook.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -42,7 +42,6 @@ const useRemoveExperimentAction = (
|
|
|
42
42
|
},
|
|
43
43
|
): DocumentFieldActionItem => {
|
|
44
44
|
const {onChange, active, experimentId, experimentNameOverride, variantNameOverride} = props
|
|
45
|
-
|
|
46
45
|
const handleClearAction = useCallback(() => {
|
|
47
46
|
const activeId = ['active']
|
|
48
47
|
const experiment = [experimentId]
|
|
@@ -135,6 +134,5 @@ export const ExperimentField = (
|
|
|
135
134
|
}),
|
|
136
135
|
[props, memoizedActions],
|
|
137
136
|
)
|
|
138
|
-
|
|
139
137
|
return props.renderDefault(withActionProps)
|
|
140
138
|
}
|
|
@@ -2,6 +2,7 @@ import {Card, Text} from '@sanity/ui'
|
|
|
2
2
|
import {FormEvent, useCallback, useMemo} from 'react'
|
|
3
3
|
import {
|
|
4
4
|
FormPatch,
|
|
5
|
+
getPublishedId,
|
|
5
6
|
PatchEvent,
|
|
6
7
|
set,
|
|
7
8
|
StringInputProps,
|
|
@@ -27,13 +28,13 @@ export const ExperimentInput = (
|
|
|
27
28
|
const {experiments} = useExperimentContext()
|
|
28
29
|
|
|
29
30
|
const id = useFormValue(['_id']) as string
|
|
30
|
-
const
|
|
31
|
+
const additionalChangePath = useMemo(
|
|
31
32
|
() => [...props.path.slice(0, -1), `${props.variantNameOverride}s`],
|
|
32
33
|
[props.variantNameOverride, props.path],
|
|
33
34
|
)
|
|
35
|
+
const subValues = useFormValue(additionalChangePath)
|
|
34
36
|
|
|
35
|
-
const
|
|
36
|
-
const {patch} = useDocumentOperation(id.replace('drafts.', ''), props.schemaType.name)
|
|
37
|
+
const {patch} = useDocumentOperation(getPublishedId(id), props.schemaType.name)
|
|
37
38
|
|
|
38
39
|
const handleChange = useCallback(
|
|
39
40
|
(
|
|
@@ -51,12 +52,12 @@ export const ExperimentInput = (
|
|
|
51
52
|
|
|
52
53
|
if (subValues) {
|
|
53
54
|
const patchEvent = {
|
|
54
|
-
unset: [
|
|
55
|
+
unset: [additionalChangePath.join('.')],
|
|
55
56
|
}
|
|
56
57
|
patch.execute([patchEvent])
|
|
57
58
|
}
|
|
58
59
|
},
|
|
59
|
-
[patch, subValues,
|
|
60
|
+
[patch, subValues, additionalChangePath],
|
|
60
61
|
)
|
|
61
62
|
|
|
62
63
|
if (!experiments.length)
|