question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enhance `BannerNotification` to better support an elemental `description`

See original GitHub issue

Feature Description

The BannerNotification component currently allows for a non-scalar description to be provided in the form of a React element. If provided it allows for more control over that part of the output but currently somewhat enforces that the given element is a valid child of a p tag since the entire description is always rendered within one. This undermines the purpose of the prop’s flexibility and requires consumers to do odd things (e.g. if multiple paragraphs were desired instead of one) to work around it.

screenshot

https://github.com/google/site-kit-wp/blob/da8f2f9d312a71f0806888968fed60190a6d7bf9/assets/js/components/notifications/BannerNotification/index.js#L287-L292


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • BannerNotification should be updated such that if a valid element is provided for its description, the given description is rendered as-is (without an added wrapper).
    • The case for when a non-element is provided should be updated to render the p tag with inner HTML set as it is now on the span tag
  • Consuming use of BannerNotification should be updated to preserve the current styling where needed although exceptions can me made on a case-by-case basis.

Implementation Brief

  • In assets/js/components/notifications/BannerNotification/index.js:
    • In the inlineMarkup variable assignment, locate the <p> tag inside the .googlesitekit-publisher-win__desc element.
    • Remove this wrapping <p> tag preserving all its internal contents.
    • In the condition where the description prop is not a valid element, wrap the existing <span> tag with a new <p> tag.
    • Wrap the adjacent elements, i.e. the “learn more” link and the “page index” in a new <p> tag.
  • In assets/js/components/notifications/ThankWithGoogleSupporterWallNotification.js:
    • In the rendered <BannerNotification> component, update the description prop so that its contents are wrapped with a <p> tag instead of a <Fragment>.
  • In assets/js/components/ErrorHandler/index.js:
    • In the rendered <BannerNotification> (imported as <Notification>) component, update the description prop so that its contents are wrapped with a <p> tag instead of a <Fragment>.

Test Coverage

  • No tests need to be added/updated. Optionally/time-permitting: add a few tests to cover this behaviour.
  • Update VRT references if required.

QA Brief

  • Check notification banners to appear and function correctly on a page and no Warning (from AC) appears on the page. (Eg. ActivationBanner, ThankWithGoogleSupporterWallNotification, SetupSuccessBannerNotification, AdSenseAlerts etc…)
  • Description part of a banner should always appear inside single <p> as per the screenshot below: Screenshot 2022-10-18 at 13 47 36

( This ticket is technical and brings no updates to UI/UX. All functionality should remain the same )

Changelog entry

  • Enhance the BannerNotification component to better support a description which is a React element.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
tofumattcommented, Oct 26, 2022

@techanvil pointed out that some questions around layout weren’t 100% answered here, but we shouldn’t change the visual layout of the “Learn more” link in this example.

It’s okay to change the markup here to something a bit more semantic (a <p> link @nfmohit proposed, or even a <div>), but visually the “Learn more” link or other text that would accompany that content should—by default—be inline and not on a new line.

Eg. This is the correct visual layout:

image

1reaction
tofumattcommented, Oct 10, 2022

Looks good, but this is probably a 7 estimate, as a fair number of components are affected and should be reviewed/QA’d.

Plus: it’d be good to add a test or two for this new behaviour to make sure it’s preserved. I added mention of this to the IB, but otherwise looks good.

IB ✅

Read more comments on GitHub >

github_iconTop Results From Across the Web

Banners - Material Design
A banner displays an important, succinct message, and provides actions for users to address (or dismiss the banner). It requires a user action...
Read more >
ARIA: banner role - Accessibility - MDN Web Docs - Mozilla
A banner landmark role overwrites the implicit ARIA role of the container element upon which it is applied. It should be reserved for...
Read more >
Notifications - Carbon Design System
Banners take over the top of an interface to show general notifications for the product or system, not a specific task. They persist...
Read more >
Promoting Apps with Smart App Banners - Apple Developer
Overview. Smart App Banners vastly improve users' browsing experience ... Smart App Banners automatically determine whether the user's device supports your ...
Read more >
The influence of banner advertisements on attention and ...
Memorability of the brand and advertising message was also enhanced. Conversely, in the condition involving faces with mutual gaze, the focus of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found