[Feature Request] For web renders, let `Icon` and `Chip` render as `<button>` only if it needs to be clickable
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- react, react-native
- Domain
- frontend
Research direction
Start by tracing the web-rendering paths for Icon, Chip, and Button and reproduce the validateDOMNesting warning described in the issue. Compare behavior with and without onPress or related callbacks; done means non-clickable components no longer create nested button elements while clickable behavior remains available.
Written by the indexing model from the issue text.
Description
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:
Iconneed not behave as an HTML<button>if there are noonPressor related callbacks defined.- As an extension to the above:
Iconshould not allowonPressor related callbacks in case it is used as a child component of aButton - [Optional, but I think this is good]
Chipneed not behave as aButtonbecause 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,Chipcan have a clickableIcon.
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
- Dominant language
- MDX
- Stars
- 25.9k
- Forks
- 4.7k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from react-native-elements/react-native-elements
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
react-native-elements/react-native-elements#4035 · 1 comment ·
-
Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
react-native-elements/react-native-elements#3963 · 2 comments · 2 reactions ·
-
component: Button
react-native-elements/react-native-elements#4032 · 1 assignee ·
-
TS Bug - @rneui/base@5.0.0 — Undeclared type dependency causes IconProps to lose color/name/size Opencomponent: Icon
react-native-elements/react-native-elements#4027 · 2 comments · 4 reactions · 1 assignee ·
-
📞 Needs Response from Author
react-native-elements/react-native-elements#4022 · 9 comments · 2 reactions · 1 assignee ·
All issues in react-native-elements/react-native-elements
Similar issues
-
react-doctor severity:warning tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
digidem/comapeo-cloud-app#401 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
zostera/django-bootstrap4#894 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
pnp/sp-dev-fx-controls-react#2156 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
eknowledger/toolbench#101 · 1 comment ·