Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Migrate result variants selector component #1438

Merged
merged 12 commits into from
Apr 8, 2024
Merged
Prev Previous commit
Next Next commit
feat: fix selected variant inject + back to array obj check
  • Loading branch information
annacv committed Mar 26, 2024

Verified

This commit was signed with the committer’s verified signature.
jschwe Jonathan Schwender
commit 5f121359b810b8357351f6130e4a3d530ca7360a
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@
* @returns The 'selectResultVariant' injection key.
*/
const selectResultVariant = useHybridInject<
Ref<(variant: ResultVariant, level?: number) => void | undefined>
Ref<(variant: ResultVariant, level?: number) => void>
>(SELECT_RESULT_VARIANT_KEY as string);

/**
@@ -102,7 +102,7 @@
*
* @public
*/
const selectedVariants: ResultVariant[] | undefined = useHybridInject(
const selectedVariants = useHybridInject<Ref<ResultVariant[]>>(
SELECTED_VARIANTS_KEY as string
);

@@ -116,7 +116,7 @@
if (props.level === 0) {
return result!.variants;
}
return selectedVariants![props.level - 1]?.variants;
return selectedVariants!.value[props.level - 1]?.variants;
});

/**
@@ -126,7 +126,7 @@
* @internal
*/
const selectedVariant = computed<ResultVariant | undefined>(() => {
return variants.value?.find(variant => variant === selectedVariants![props.level]);
return variants.value?.find(variant => variant === selectedVariants!.value[props.level]);
});

/**
2 changes: 1 addition & 1 deletion packages/x-components/src/composables/use-hybrid-inject.ts
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ const makeInjectionReactive = <SomeValue>(
) {
const xRefValue = injection.value;

if (xRefValue && typeof xRefValue === 'object') {
if (xRefValue && typeof xRefValue === 'object' && !Array.isArray(xRefValue)) {
return reactive(xRefValue);
} else {
return ref<SomeValue>(xRefValue);
Loading