Forráskód Böngészése

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
Elijah Ahianyo 1 éve
szülő
commit
eeff4142ab

+ 12 - 0
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

+ 3 - 0
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."""