-
Notifications
You must be signed in to change notification settings - Fork 66
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
[DEVHUB-1898, UP-6913] Add Hotkey Indicator to Chat InputBar Component #2476
Conversation
🦋 Changeset detectedLatest commit: 9b53526 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
38750a9
to
166e450
Compare
Size Change: +910 B (+0.07%) Total Size: 1.36 MB
ℹ️ View Unchanged
|
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.
looks good so far! mostly was curious about if the hotkey indicator should be doing something
…ldRenderHotkeyIndicator is true
@stephl3 I tried utilizing I'm also wondering if I should swap over the prop name to something else now that it controls both the presentational and the interactive elements. If you have any suggestions (or think that the current prop name is fine), let me know! |
useEventListener('keydown', (e: KeyboardEvent) => { | ||
if ( | ||
!e.repeat && | ||
e.key === '/' && | ||
shouldRenderHotkeyIndicator && | ||
!isFocused && | ||
textareaRef.current | ||
) { |
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.
useEventListener
takes an optional 3rd argument of option
. There's an enabled
param that can contain some of the if statements
useEventListener('keydown', (e: KeyboardEvent) => { | |
if ( | |
!e.repeat && | |
e.key === '/' && | |
shouldRenderHotkeyIndicator && | |
!isFocused && | |
textareaRef.current | |
) { | |
useEventListener('keydown', (e: KeyboardEvent) => { | |
if ( | |
!e.repeat && | |
e.key === '/' | |
) { | |
... | |
} | |
}, | |
shouldRenderHotkeyIndicator & | |
!isFocused && | |
textareaRef.current, | |
); |
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.
Just fyi, had to keep the textareaRef.current
check inside the hook body because of a failing test -- I think the component wasn't being re-rendered when the ref attached resulting in the hook being out-of-date (i.e. enabled
stayed false and it wasn't picking up any keyboard inputs when it should have been)
!isFocused && | ||
textareaRef.current | ||
) { | ||
e.preventDefault(); |
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.
does this also need e.stopPropagation()
? when I tested it in storybook, the hotkey is overridden by storybook's /
hotkey
) { | ||
e.preventDefault(); | ||
textareaRef.current.focus(); | ||
setIsFocused(true); |
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.
TextareaAutosize
has an onFocus
listener that also calls setIsFocused(true);
. Does it need to be called here as well or should we drop this one?
weird, I wonder why that is. maybe something to do with how the styles are applied by emotion. the animation approach looks good!
not really sure. couple other ideas I can think of are |
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.
LGTM!
✍️ Proposed changes
Adds
shouldRenderHotkeyIndicator
prop to the InputBar component for chat. This is going to be used for the chatbot integration on DevCenter and University.First time raising a PR to LG, so let me know if I missed anything
🎟 Jira ticket: DEVHUB-1898, UP-6913
✅ Checklist
For bug fixes, new features & breaking changes
yarn changeset
and documented my changesFor new components
🧪 How to test changes
Hotkey indicator should be shown when the
shouldRenderHotkeyIndicator
prop is set to true: