Skip to content

fix: make ActionableNotification subtitle proptypes node to allow objects#13821

Merged
kodiakhq[bot] merged 9 commits into
carbon-design-system:mainfrom
crhuff-ibm:notification-subtitle-proptype
Jun 23, 2023
Merged

fix: make ActionableNotification subtitle proptypes node to allow objects#13821
kodiakhq[bot] merged 9 commits into
carbon-design-system:mainfrom
crhuff-ibm:notification-subtitle-proptype

Conversation

@crhuff-ibm

@crhuff-ibm crhuff-ibm commented May 17, 2023

Copy link
Copy Markdown
Contributor

Make actionable notification subtitle proptypes to allow more than just a string. If the consumer wants things like bold text, hyperlinks, multiple lines for text, a string doesn't allow it without throwing warnings.

Changelog

Changed

  • Notification prop types for subtitle

Testing / Reviewing

Test Inline or Actionable Notification with subtitle={<div>text</div>} instead of subtitle="text" and view no warnings.

@crhuff-ibm crhuff-ibm requested a review from a team as a code owner May 17, 2023 20:29
@netlify

netlify Bot commented May 17, 2023

Copy link
Copy Markdown

Deploy Preview for carbon-components-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 923ef2c
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/6465392f7734ef0008b0a6cb
😎 Deploy Preview https://deploy-preview-13821--carbon-components-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify

netlify Bot commented May 17, 2023

Copy link
Copy Markdown

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 923ef2c
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/6465392f549d6f00088f9b63
😎 Deploy Preview https://deploy-preview-13821--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify

netlify Bot commented May 17, 2023

Copy link
Copy Markdown

Deploy Preview for carbon-components-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 9ab62e2
🔍 Latest deploy log https://app.netlify.com/sites/carbon-components-react/deploys/6495dd33bb91850008c4d8c7
😎 Deploy Preview https://deploy-preview-13821--carbon-components-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify

netlify Bot commented May 17, 2023

Copy link
Copy Markdown

Deploy Preview for carbon-elements ready!

Name Link
🔨 Latest commit 9ab62e2
🔍 Latest deploy log https://app.netlify.com/sites/carbon-elements/deploys/6495dd3294737500084b97a3
😎 Deploy Preview https://deploy-preview-13821--carbon-elements.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@crhuff-ibm crhuff-ibm requested a review from a team as a code owner May 17, 2023 21:31

@tay1orjones tay1orjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this change should probably only be made to ActionableNotification.

InlineNotification and ToastNotification can only have a role of alert, status, or log, which means:

  • All semantic value (rich text, line breaks, etc) placed in the subtitle would not be read by screenreaders.
  • These components can't contain interactive elements like hyperlinks

For those reasons I think it makes the most sense to keep subtitle as a plain string in InlineNotification and ToastNotification.

Opening up subtitle to be a node in ActionableNotification should be fine though because it gets a role of alertdialog, which preserves semantic value and can include interactive elements.

@crhuff-ibm

Copy link
Copy Markdown
Contributor Author

Our use case for adding node to Inline is that we want text decoration within the notification. Is there any recommendation on how to approach that?

@tay1orjones tay1orjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@crhuff-ibm Sorry for the delayed response here. If you're using any rich text decoration you'll need to use ActionableNotification.

I've updated the PR so that ActionableNotification's actionButtonLabel is now optional and the button isn't rendered if the actionButtonLabel isn't provided. This makes it so you can configure just subtitle without an action.

With this PR, your usage would look something like this:

export default function App() {
  const subtitle = (
    <span>
      I've got some <strong>rich</strong> <em>text</em>{' '}
      <strong>
        <em>here</em>
      </strong>
    </span>
  );
  return (
    <div>
      <ActionableNotification inline subtitle={subtitle} />
    </div>
  );
}

@tay1orjones tay1orjones requested a review from tw15egan June 23, 2023 17:06
@tay1orjones tay1orjones changed the title fix: make notification subtitle proptypes node to allow objects fix: make ActionableNotification subtitle proptypes node to allow objects Jun 23, 2023

@tw15egan tw15egan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ideal tradeoff 👍🏻
LGTM 👍 ✅

@crhuff-ibm

Copy link
Copy Markdown
Contributor Author

Deal, thank you for the compromise!

@kodiakhq kodiakhq Bot merged commit c3ea7c8 into carbon-design-system:main Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants