Repository navigation
fix(markups): guard UserMention against missing MarkupInteractionContext - #1483
Open
swarnendusahu10-dotcom wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1482
Problem
Scrolling up to load older messages containing UIKit blocks with
@mentionscrashes EmbeddedChat to a blank white screen with:Uncaught TypeError: Cannot read properties of undefined (reading 'members')FuselageSurfaceRenderer(in@embeddedchat/ui-kit) renders<Markup>formrkdwntext without wrapping it in<MarkupInteractionContext.Provider>.MarkupInteractionContextwas initialized withcreateContext()(undefineddefault).UserMentiondestructured{ members, username }directly fromuseContext(MarkupInteractionContext), throwing aTypeErrorwhenever the provider was absent.Changes
packages/markups/src/MarkupInteractionContext.js:{ members: [], username: '' }tocreateContext(...).packages/markups/src/mentions/UserMention.js:|| {}fallback when destructuringMarkupInteractionContextandRCContext(handles explicitundefined/nullprovider values).hasMemberagainstnull/ non-objectmembersandnullmember entries usingObject.values(members).some((member) => member?.username === user).handleUserInfowith optional chaining (RCInstance?.userData),data?.usercheck, andtry/catch.tooltipMapso an emptyusernamedoes not collide with empty values, and used optional chaining oncontents?.value..changeset/fix-user-mention-missing-context.md: Added patch changeset for@embeddedchat/markups.Verification
@embeddedchat/markupsRollup build (yarn build): exited cleanly with code 0.