Sep 20, 2024
  • BraidTestProvider: Provide scrollIntoView stub function for jsdom

    Fixes an issue where scrollIntoView is not defined in jsdom, causing tests to fail with the following error:

    Error: Uncaught [TypeError: highlightedItem?.scrollIntoView is not a function]
Nov 23, 2021
  • BraidTestProvider: Move to separate entry

    By moving BraidTestProvider to it’s own entry, we can prevent importing all the themes at dev-time. This improves the developer experience when debugging the stylesheet that is output by the development server.

    MIGRATION GUIDE

    Migration can largely be automated by running the Braid upgrade command. You must provide a glob to target your project’s source files. For example:

    yarn braid-upgrade v31 "**/*.{ts,tsx}"

    It may be necessary to manually migrate code in some cases, here are the affected use cases:

    - import { BraidTestProvider } from 'braid-design-system';
    + import { BraidTestProvider } from 'braid-design-system/test';
Aug 14, 2020
  • Added support for refs on Link

    Forwarding refs is necessary for certain accessibility patterns (e.g. managing focus states), but the Link component wasn't doing this correctly.

    Please note that, if you're passing a custom linkComponent implementation to BraidProvider, you'll need to ensure that you're using the new makeLinkComponent helper function to forward refs, otherwise any attempt to pass a ref to Link will throw an error.

    MIGRATION GUIDE

    -import { BraidProvider, LinkComponent } from 'braid-design-system';
    +import { BraidProvider, makeLinkComponent } from 'braid-design-system';
    
    -const CustomLink: LinkComponent = ({ href, ...restProps }) =>
    +const CustomLink = makeLinkComponent({ href, ...restProps }, ref) =>
      href[0] === '/' ? (
    -    <ReactRouterLink to={href} {...restProps} />
    +    <ReactRouterLink to={href} {...restProps} ref={ref} />
      ) : (
    -    <a href={href} {...restProps} />
    +    <a href={href} {...restProps} ref={ref} />
      );
    
    export const App = () => (
      <BraidProvider linkComponent={CustomLink} {...rest}>
        ...
      </BraidProvider>
    );
Mar 13, 2020
  • Add BraidTestProvider component.

    This is an alternative to BraidProvider for unit test environments. Note that, as the name implies, this should not be used in production code.

    MIGRATION GUIDE

    In your unit tests, you can replace usage of BraidProvider with BraidTestProvider, omitting the theme.

    -<BraidProvider theme={wireframe}>
    +<BraidTestProvider>

    If for whatever reason your tests are relying on the presence of a specific theme, you can pass the name of the desired theme.

    -<BraidProvider theme={seekAnz}>
    +<BraidTestProvider themeName="seekAnz">