Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

🐛 fix broken sidebar after successful import #658

Merged

Conversation

kevinansfield
Copy link
Member

closes TryGhost/Ghost#8307

  • unloading the store and refreshing the session.user attribute after an import was triggering a rendering edge case where the style was re-computed and a re-render was attempted after the sidebar has been destroyed
  • rather than binding a style attribute directly to a CP in gh-nav-menu we pass the menu icon in (using settings.settledIcon - see below) and manually set the style attribute via the didReceiveAttrs hook so that outside changes don't trigger re-computations when we don't expect them and so we can still react to icons being uploaded or removed
  • our usage of settings.icon is a bit of an odd situation because it's a link to an external resource that will only resolve correctly after a successful save - if we change settings.icon in the local store and the nav menu icon style updates before the save has been completed then the server will give us the old icon. To work around this a settings.settledIcon attribute has been added that is only updated when we receive data from the store ensuring that our cache-busting technique works correctly

- unloading the store and refreshing the `session.user` attribute after an import was triggering a rendering edge case where the style was re-computed and a re-render was attempted after the sidebar has been destroyed
- rather than binding a style attribute directly to a CP in `gh-nav-menu` we pass the menu icon in (using `settings.settledIcon` - see below) and manually set the style attribute via the `didReceiveAttrs` hook so that outside changes don't trigger re-computations when we don't expect them and so we can still react to icons being uploaded or removed
- our usage of `settings.icon` is a bit of an odd situation because it's a link to an external resource that will only resolve correctly after a successful save - if we change `settings.icon` in the local store and the nav menu icon style updates before the save has been completed then the server will give us the old icon. To work around this a `settings.settledIcon` attribute has been added that is only updated when we receive data from the store ensuring that our cache-busting technique works correctly
@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 73.32% when pulling de82b5e on kevinansfield:fix-missing-sidebar-after-import into ff12348 on TryGhost:master.

@kirrg001 kirrg001 self-assigned this Apr 19, 2017
Copy link
Contributor

@kirrg001 kirrg001 left a comment

Choose a reason for hiding this comment

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

works 👍

Just wondered if the whole reload of the menu is normal?

If yes, you can self merge later 🙃

@kirrg001
Copy link
Contributor

Yeah that's normal unfortunately, the import removes all local data before reloading so some parts can't be rendered in-between.

@kirrg001 kirrg001 merged commit 6ef7fca into TryGhost:master Apr 19, 2017
@kevinansfield kevinansfield deleted the fix-missing-sidebar-after-import branch June 4, 2018 10:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After import database, menu disappears
3 participants