Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

fix(docs): component styles in RTL mode#579

Merged
kuzhelov merged 6 commits intomasterfrom
fix/docs-rtl-styles
Dec 8, 2018
Merged

fix(docs): component styles in RTL mode#579
kuzhelov merged 6 commits intomasterfrom
fix/docs-rtl-styles

Conversation

@kuzhelov
Copy link
Contributor

@kuzhelov kuzhelov commented Dec 7, 2018

Currently all the component styles are broken for docs in RTL mode. This PR fixes this problem.

TODO

  • update changelog

What was the issue

The root cause of that is the fact that Fela updates subscription to the DOM node where styles should be rendered to (i.e <head> -> <styles>) only on its Provider component being mounted.

It turns out that our rendering loigc hasn't guaranteed that new Fela's Provider will be mounted with RTL switch - and, this, the logic of <style> DOM node subscription wasn't fired for RTL renderer.

Fixes: #582

Follow-up, general issue: #581


return <Provider theme={newTheme}>{element}</Provider>
return (
<Provider key={`${examplePath}${showRtl ? '-rtl' : ''}`} theme={newTheme}>
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should be done in the Provider itself? It seems adding it here would means RTL will work in our doc examples, but not necessarily anywhere else the Provider is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure, as there is no straightforward way to generate the key (as we won't like to generate a new one on each rerendering). Should we request client to provide it?

Copy link
Contributor Author

@kuzhelov kuzhelov Dec 7, 2018

Choose a reason for hiding this comment

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

or you would suggest to do it here?

// Provider.ts
...
   <ProviderConsumer
      render={(incomingTheme: ThemePrepared) => {
      const outgoingTheme: ThemePrepared = mergeThemes(incomingTheme, theme)

      return (
          <RendererProvider renderer={outgoingTheme.renderer} {...{ rehydrate: false }}>
             <ThemeProvider key={outgoingTheme.isRtl ? 'rtl' : 'ltr'} theme={outgoingTheme}>{children}</ThemeProvider>
          </RendererProvider>
       )
    }}
   />

Copy link
Member

@levithomason levithomason left a comment

Choose a reason for hiding this comment

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

Just add a TODO and link to this issue to fix it in the Provider

@kuzhelov kuzhelov merged commit 0cb1b48 into master Dec 8, 2018
@kuzhelov kuzhelov deleted the fix/docs-rtl-styles branch December 8, 2018 14:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🧰 fix Introduces fix for broken behavior. 🚀 ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTL mode breaks styles in docs

3 participants