Skip to content

Components: Notice: Handle spoken message from component, not store #15708

Closed

Description

@aduth

Previously: https://github.com/WordPress/gutenberg/pull/15594/files#r284613950

Currently, it is the responsibility of the notices store to emit the spoken message when a notice is created. While this ensures that any notice which operates via the createNotice store action will be spoken, it misses messages which may be displayed by using the Notice component directly. If it's agreeable that a spoken message be considered as a necessary element of the displayed notice, it would therefore make sense to migrate this out of the data store and instead implemented as an effect of the component.

Implementation notes:

Remove SPEAK control yielding and control handler:

if ( speak ) {
yield { type: 'SPEAK', message: content };
}

SPEAK( action ) {
speak( action.message, 'assertive' );
},

Implement instead as part of lifecycle of the component:

https://github.com/WordPress/gutenberg/blob/master/packages/components/src/notice/index.js

Likely using useEffect to emulate componentDidMount and componentDidUpdate:

https://reactjs.org/docs/hooks-effect.html

If #15594 is merged, it adds additional consideration for polite and assertive spoken messages. This should be handled instead from the Notice and Snackbar components.

Activity

  1. youknowriad commented on May 20, 2019

    @youknowriad
    Contributor

    Noting that solving this would fix #9442

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo