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 Request] For web renders, let Icon and Chip render as <button> only if it needs to be clickable #3888

Open
utkarsh1097 opened this issue Feb 8, 2024 · 1 comment

Comments

@utkarsh1097
Copy link

utkarsh1097 commented Feb 8, 2024

Is your feature request related to a problem? Please Describe.

Please refer to #3857

Tl;dr: Button with underlying Icon and Chip with underlying Icon causes validateDOMNesting check to fail for web renders because of nested <button>.

Describe the solution you'd like

To mitigate this, I propose the following changes:

  1. Icon need not behave as an HTML <button> if there are no onPress or related callbacks defined.
  2. As an extension to the above: Icon should not allow onPress or related callbacks in case it is used as a child component of a Button
  3. [Optional, but I think this is good] Chip need not behave as a Button because according to the docs: "Chips are compact elements that represent an input, attribute, or action. They may display text, icons, or both". My understanding is that they can also be used as "discrete labels/tags" to associate some sort of metadata (similar to "Labels" in Jira or "Multi-Select Tags" in Notion). In that case, Chip can have a clickable Icon.

Describe alternatives you've considered

<Icon.Button> from react-native-vector-icons conditionally be a functional replacement to <Button icon={}>, but it is less flexible.

Additional context

@yuryibaravy
Copy link

would be great to see this issue fixed & merged, coz now it's super strange to see button inside button after build, despite docs show possibility to use Icon inside Button component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants