dxc-technology / halstack-react

Library of components for building SPAs with React and Halstack Design System
https://developer.dxc.com/halstack/
Apache License 2.0
15 stars 14 forks source link

Typography allows invalid HTML tags in `as` prop #1621

Closed GomezIvann closed 6 months ago

GomezIvann commented 1 year ago

Describe the bug Some HTML tags we consider valid for as prop of the DxcTypography component are not so. For example, the tags <br /> and <col /> do not have children, both in HTML and React, which is causing our component to break. We need to restrict the possible values of this prop.

Mil4n0r commented 10 months ago

I see 2 possible approaches here:

  1. Accepting any string that is considered a tagname in the "as" parameter except for those that match a void element tag (br, img, area...)
  2. Accepting only those "as" parameters that match with what is expected from a Typography component (we would have to discuss which ones those should be, aside from the typical span, div, p, h1, h2, h3...)

I honestly think that the second approach would be more appropiate.

GomezIvann commented 10 months ago

I agree, the second option is the best one. But first, we need to discuss the tags that we want to allow.

Mil4n0r commented 10 months ago

I suggested a list of allowed tags in the additional context of the PR (#1765). We can create a discussion related to it if needed.

github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 15 days with no activity. If there are no further updates or modifications within the next 15 days, it will be automatically closed.