-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Added unFocusTextArea to manage text area blur functionality #286
Added unFocusTextArea to manage text area blur functionality #286
Conversation
b5a3bcc
to
3e7d639
Compare
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.
Thank you for the PR 😊 Some nits to fix!
const callRcbEventMock = jest.fn(); | ||
mockUseRcbEventInternal.mockReturnValue({ | ||
callRcbEvent: callRcbEventMock, | ||
}); |
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 actually unused, the text area currently only emits an event for text change. That said, it might be a good idea to emit events for focusing/blurring the text area in future (topic for another time).
@@ -105,7 +105,16 @@ export const useTextAreaInternal = () => { | |||
}, [textAreaDisabled]); | |||
|
|||
/** | |||
* Retrieves text area value. | |||
* Focuses on text area. |
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 comment needs to be updated as well.
* Retrieves text area value. | ||
* Focuses on text area. | ||
*/ | ||
const unFocusTextArea = useCallback(() => { |
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.
Instead of unFocusTextArea
, let's go with blurTextArea
which will be better inline with the DOM APIs (do rename the relevent parts accordingly).
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.
applied 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.
Thanks for the changes!
Description
This PR introduces the
unFocusTextArea
functionality in theuseTextAreaInternal
hook, which allows programmatic removal of focus from the text area. This complements the existingfocusTextArea
method and provides additional control over the text area's behavior.Closes #(issue)
What change does this PR introduce?
Please select the relevant option(s).
NA
What is the proposed approach?
The unFocusTextArea method was added as a useCallback function within the useTextAreaInternal hook. It leverages the blur method on the inputRef to remove focus from the text area. Additionally, a new test case was created to verify this behavior, ensuring it works as intended without impacting existing functionality.
Checklist: