From eeff4142ab291c3b63ced32534e79771eaa33a51 Mon Sep 17 00:00:00 2001 From: Elijah Ahianyo Date: Tue, 20 Feb 2024 17:57:01 +0000 Subject: [PATCH] Accordion Root Exclude `color_scheme` and `variant` props in tag (#2664) * Accordion Root Exclude `color_scheme` and `variant` props in tag * colorScheme -> color for radix primitives * remove _rename_props based on pr comments * lint * pyi fix * pop instead of del --- reflex/components/component.py | 12 ++++++++++++ reflex/components/radix/primitives/accordion.py | 3 +++ 2 files changed, 15 insertions(+) diff --git a/reflex/components/component.py b/reflex/components/component.py index e619b7004..3a84b8f8d 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -502,6 +502,14 @@ class Component(BaseComponent, ABC): if isinstance(child, Component): child.apply_theme(theme) + def _exclude_props(self) -> list[str]: + """Props to exclude when adding the component props to the Tag. + + Returns: + A list of component props to exclude. + """ + return [] + def _render(self, props: dict[str, Any] | None = None) -> Tag: """Define how to render the component in React. @@ -544,6 +552,10 @@ class Component(BaseComponent, ABC): props.update(self._get_style()) props.update(self.custom_attrs) + # remove excluded props from prop dict before adding to tag. + for prop_to_exclude in self._exclude_props(): + props.pop(prop_to_exclude, None) + return tag.add_props(**props) @classmethod diff --git a/reflex/components/radix/primitives/accordion.py b/reflex/components/radix/primitives/accordion.py index cf5e630ab..4394f1f30 100644 --- a/reflex/components/radix/primitives/accordion.py +++ b/reflex/components/radix/primitives/accordion.py @@ -463,6 +463,9 @@ to { ` """ + def _exclude_props(self) -> list[str]: + return ["color_scheme", "variant"] + class AccordionItem(AccordionComponent): """An accordion component."""