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: chat composer examples for handle change events #3426
Conversation
Run & review this pull request in StackBlitz Codeflow. |
π¦ Changeset detectedLatest commit: b7ae455 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
import merge from 'deepmerge'; | ||
|
||
import {chatComposerLexicalStyles} from './styles'; | ||
import {AutoLinkPlugin} from './AutoLinkPlugin'; | ||
import {PlaceholderWrapper} from './PlaceholderWrapper'; | ||
import {baseConfig, renderInitialText} from './helpers'; | ||
|
||
export interface ChatComposerProps extends ContentEditableProps { | ||
export interface ChatComposerProps extends Omit<ContentEditableProps, 'style' | 'className' | 'onChange'> { |
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.
Rather than set them to never, just don't allow them. And new onChange types from ContentEditable clash so remove that too
β Deploy Preview for paste-theme-designer ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
children?: LexicalComposerProps['children']; | ||
config: LexicalComposerProps['initialConfig']; | ||
element?: BoxProps['element']; | ||
placeholder?: string | JSX.Element; |
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.
unsure on this one, it clashes now and I don't really know why we would change it from what is supplied in the ContentEditable types
β Deploy Preview for paste-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
maxHeight?: BoxStyleProps['maxHeight']; | ||
initialValue?: string; | ||
disabled?: boolean; | ||
|
||
/** Mapped to ariaOwneeID on the Lexical ContentEditable component. */ | ||
ariaOwns?: ContentEditableProps['ariaOwneeID']; |
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.
They've fixed all these issues now, so no need to rewire them. And we handle the banned props
@@ -6,7 +6,7 @@ import { | |||
MinimizableDialogHeader, | |||
MinimizableDialogContent, | |||
} from '@twilio-paste/minimizable-dialog'; | |||
import {AutoScrollPlugin, $getRoot, ClearEditorPlugin} from '@twilio-paste/lexical-library'; | |||
import {$getRoot, ClearEditorPlugin} from '@twilio-paste/lexical-library'; |
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.
AutoScrollPlugin is removed from lexical
βοΈ Nx Cloud ReportCI is running/has finished running commands for commit b7ae455. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. π See all runs for this branch β Successfully ran 1 targetSent with π from NxCloud. |
@@ -121,6 +120,7 @@ export const ConversationsUIKitExample: StoryFn = () => { | |||
}; | |||
|
|||
const submitMessage = (): void => { | |||
if (message === '') return; |
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.
prevent empty bubbles
@@ -132,11 +132,10 @@ export const ConversationsUIKitExample: StoryFn = () => { | |||
<MinimizableDialog aria-label="Live chat"> | |||
<MinimizableDialogHeader>Live chat</MinimizableDialogHeader> | |||
<MinimizableDialogContent> | |||
<Box overflowY="scroll" maxHeight="size50" tabIndex={0}> | |||
<Box overflow="hidden" overflowY="scroll" maxHeight="size50" tabIndex={0}> |
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.
Stops the weird scroll behaviour as you animate in new bubbles
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.
But does it scroll? [edit] Seems like it does.
@@ -41,6 +41,7 @@ export const ChatBubble = React.forwardRef<HTMLDivElement, ChatBubbleProps>( | |||
element={element} | |||
ref={ref} | |||
variant={variant} | |||
whiteSpace="pre-wrap" |
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.
Solves the line breaks in user generated strings
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.
Oh, neat
Passing run #6616 βοΈ
Details:
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
Size Change: +10.7 kB (+1%) Total Size: 1.01 MB
βΉοΈ View Unchanged
|
β Deploy Preview for paste-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit b7ae455:
|
"lexical": "0.6.0" | ||
"@lexical/link": "0.12.0", | ||
"@lexical/react": "0.12.0", | ||
"lexical": "0.12.0" |
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 is a big jump, wow.
@@ -41,6 +41,7 @@ export const ChatBubble = React.forwardRef<HTMLDivElement, ChatBubbleProps>( | |||
element={element} | |||
ref={ref} | |||
variant={variant} | |||
whiteSpace="pre-wrap" |
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.
Oh, neat
@@ -132,11 +132,10 @@ export const ConversationsUIKitExample: StoryFn = () => { | |||
<MinimizableDialog aria-label="Live chat"> | |||
<MinimizableDialogHeader>Live chat</MinimizableDialogHeader> | |||
<MinimizableDialogContent> | |||
<Box overflowY="scroll" maxHeight="size50" tabIndex={0}> | |||
<Box overflow="hidden" overflowY="scroll" maxHeight="size50" tabIndex={0}> |
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.
But does it scroll? [edit] Seems like it does.
packages/paste-website/src/pages/components/chat-composer/index.mdx
Outdated
Show resolved
Hide resolved
packages/paste-website/src/pages/components/chat-composer/index.mdx
Outdated
Show resolved
Hide resolved
packages/paste-website/src/pages/components/chat-composer/index.mdx
Outdated
Show resolved
Hide resolved
packages/paste-website/src/pages/components/chat-composer/index.mdx
Outdated
Show resolved
Hide resolved
expect(screen.getByRole('textbox')).toBeDefined(); | ||
expect(screen.getByText('Type here..')).toBeDefined(); | ||
}); | ||
|
||
it('should pass props to the content editable', async () => { | ||
render( | ||
<ChatComposer | ||
testid="my-composer" | ||
data-testid="my-composer" |
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 have no idea how these tests were actually working. testid
isn't a valid html prop, it should never have worked.
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.
lol
Co-authored-by: Sarah <sali@twilio.com>
58cd0c5
to
7e5e16c
Compare
expect(screen.getByRole('textbox')).toBeDefined(); | ||
expect(screen.getByText('Type here..')).toBeDefined(); | ||
}); | ||
|
||
it('should pass props to the content editable', async () => { | ||
render( | ||
<ChatComposer | ||
testid="my-composer" | ||
data-testid="my-composer" |
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.
lol
export const createNewMessage = (message: string): Omit<Chat, 'id'> => { | ||
const time = new Date().toLocaleString('en-US', { | ||
hour: 'numeric', | ||
minute: 'numeric', | ||
hour12: true, | ||
}); | ||
|
||
const messageDirection = getRandomInt(2) === 1 ? 'inbound' : 'outbound'; |
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.
not super important but I woulda done Math.random() > 0.5 ?
}, []); | ||
|
||
React.useEffect(() => { | ||
if (!mounted || !loggerRef.current) return; |
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.
IIRC anything in a useEffect will only run after mount. Do we need the mounted
variable at all? I would figure we can remove it. If you had an unmount operation in the previous useEffect like return () => setMounted(false)
then I may not have noticed/commented.
[edit] Oh unless this is only supposed to run on updates and never on mounts. That makes sense now.
Description and useful links to discussions / issues / tickets
Changes in this PR:
Update lexical
Its old and some stuff has been deprecated
Update Chat Composer
Accomodate the new version of Lexical, remove the deprecated AutoScrollPlugin and tidy types
Update Chat Log
Better handling of line breaks in the Chat bubble. Improvements to the ChatLogger to keep new messages in view as they are added to the log, to make better website examples.
Checklist
required
checks have passedπ΅π»ββοΈ Run website visual regression
label