Remove Paragraph Tag from Alert Body
See original GitHub issueBug Report
Description
Currently the terra-alert module wraps the body of the alert in a <p>
tag. This proves problematic if a consumer uses HTML elements (which the docs state is valid input) in body of the alert as the react DOM validator outputs a warning. I have a attached a screenshot of the warning from the console below.
Steps to Reproduce
- Create a Terra Alert in a test site.
- Place a
<div>
element (or a Terra element that uses a<div>
inside the alert as a child element. - Observe the warning in the console.
Additional Context / Screenshots
Expected Behavior
I would expect that when I use HTML elements (besides a <span>
, for some reason it does not complain about a <span>
tag) or other Terra elements that use divs under the hood to not print an error.
Possible Solution
Change the Terra Alert component to use a <div>
for the body instead of a <p>
tag.
Environment
- Component Name and Version: terra-alert 2.33.0
- Browser Name and Version: Google Chrome 70.0.3538.110
- Node/npm Version: Node 8.4 npm 5.3
- Webpack Version: 4
- Operating System and version (desktop or mobile): macOS desktop
@ Mentions
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (12 by maintainers)
Top Results From Across the Web
Remove HTML tags from a javascript string - Stack Overflow
and I want to remove all <p> and </p> tags from the above string. Just want to display the string values without html...
Read more >Strip HTML Tags in JavaScript - CSS-Tricks
This solution is great for using of inner content from paragraph in JS Alert window – it strips nbsp and em efectivelly,
Read more >How to strip out HTML tags from a string using JavaScript
To strip out all the HTML tags from a string there are lots of procedures in JavaScript. In order to strip out tags...
Read more >Deep dive - Summernote
The tags can be specified just by tag name (as with p or pre or h1 - h6 above). ... Dialogs can be...
Read more >How to remove the HTML tags that are displaying in the text
Use this to remove HTML tags from rich text area field in JavaScript: const strippedString = htmlString.replace(/(<([^>]+)>)/gi, ""); console.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@gabeparra01 you are welcome to contribute this! It would be appreciated!
I did a screen reader test with Jaws and Voiceover using a div instead of a paragraph. We wanted to make sure that the title and message read as a seamless statement to browsers, and it used to break on the title with a pause before reading the alert. It must have been a style change, not a markup that changed that, so I would be okay with using a div instead of a p for alert. I do see this as a valid case for an alert banner, but I would like to double check with our designer.