-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prevent LibraryLayout remount #79
base: jill/fal-3984-fix-autofocus
Are you sure you want to change the base?
fix: prevent LibraryLayout remount #79
Conversation
5e043df
to
0c33d4c
Compare
@@ -48,7 +50,7 @@ const CollectionInfo = () => { | |||
if (componentPickerMode) { | |||
setCollectionId(collectionId); | |||
} else { | |||
navigateTo({ collectionId }); | |||
navigate(`/library/${libraryId}/collection/${collectionId}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this to differentiate "Open the collection on the sidebar" from "Open the collection page".
We could add a parameter to navigateTo
to handle this. If we go that route, would be nice also to change here:
https://github.com/openedx/frontend-app-authoring/blob/98fbcff842ed760337700e51204e17e940ee7603/src/library-authoring/components/CollectionCard.tsx#L82
I liked the way you did the navigateTo
. These hardcoded routes are not nice.
// now open the previously-selected collection, | ||
? ROUTES.COLLECTION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing a redirect to the Collection page on a second click on the collection card.
/** We need to pass the pathname as key to the LibraryProvider to force a | ||
* re-render when we navigate to a new path or page. */ | ||
key={location.pathname} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the issue where the LibraryProvider was being remounted when the location.pathname changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why were we trying to force a re-render before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we navigated to the Collection Page before, the first render still had collectionId = undefined
. Remounting the context provider fixed that. It wasn't the best workaround, but it didn't cause many side effects at the time.
88c174e
to
645e841
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## jill/fal-3984-fix-autofocus #79 +/- ##
==============================================================
Coverage ? 93.23%
==============================================================
Files ? 1098
Lines ? 21704
Branches ? 4663
==============================================================
Hits ? 20236
Misses ? 1403
Partials ? 65 ☔ View full report in Codecov by Sentry. |
No description provided.