Skip to content

Fix for react troubleshooting component heading style#5630

Merged
amathews-fs merged 6 commits intomainfrom
quick_fix_for_react_troubleshooting_heading
Nov 23, 2021
Merged

Fix for react troubleshooting component heading style#5630
amathews-fs merged 6 commits intomainfrom
quick_fix_for_react_troubleshooting_heading

Conversation

@amathews-fs
Copy link
Contributor

There was a styling bug in the TroubleShooting React component. So after a quick discussion the missing style class was added and the ability to customize the header tag in the component was introduced. This brings the react troubleshooting component in line with the ruby implementation.

…ter a quick discussion added the missing style class and the ability to customize the header tag in the component.
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but it looks like the headingTag option is never used? Are we planning to use it in the future?

Comment on lines 22 to 25
function TroubleshootingOptions({ headingTag = 'h2', headingText, options }) {
const HeadingTag = headingTag;

return (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can rename this so we don't need the separate assignment

Suggested change
function TroubleshootingOptions({ headingTag = 'h2', headingText, options }) {
const HeadingTag = headingTag;
return (
function TroubleshootingOptions({ headingTag: HeadingTag = 'h2', headingText, options }) {
return (

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not currently used but will be in the future. I can cut it out but it'll be needed when the rest of the IAL2 flow is moved into react.

* @param {TroubleshootingOptionsProps} props
*/
function TroubleshootingOptions({ heading, options }) {
function TroubleshootingOptions({ headingTag = 'h2', headingText, options }) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we call it headingLevel to match the ERB partial? Or vice-versa, update the ERB partial to match this name?

I suppose an argument could be made that "heading level" would be the numeric value, not the tag name, so either renaming both as "heading tag", or using "heading level" as a numeric value.

* @typedef TroubleshootingOptionsProps
*
* @prop {string} heading
* @prop {string=} headingTag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For your lint error, I think TypeScript is upset about accepting an arbitrary string as a tag name. It works better for me if you explicitly make it one of the heading tags we're expecting:

Suggested change
* @prop {string=} headingTag
* @prop {'h1'|'h2'|'h3'|'h4'|'h5'|'h6'=} headingTag

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I was thinking about the arbitrary nature of it but wasn't sure exactly how to address it in TS.

/**
* @typedef TroubleshootingOptionsProps
*
* @prop {string} heading
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we bring this option (back into) alignment b/w JSX and ERB?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 6516040


const heading = getByRole('heading');

expect(getByText('Need help?').tagName).to.be.equal('H2');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this have used existing heading variable? Should be the same?

Suggested change
expect(getByText('Need help?').tagName).to.be.equal('H2');
expect(heading.tagName).to.be.equal('H2');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I moved that test to a different test at the last minute and didn't really notice the heading was already pulled there.

@amathews-fs amathews-fs merged commit fc75847 into main Nov 23, 2021
@amathews-fs amathews-fs deleted the quick_fix_for_react_troubleshooting_heading branch November 23, 2021 20:25
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

Successfully merging this pull request may close these issues.

3 participants