Skip to content

Conversation

@clowreed
Copy link
Contributor

@clowreed clowreed requested review from glebovsky and zhadaev April 23, 2025 11:17
let overlay = null

React.Children.forEach(children, child => {
if (child.type && child.type.displayName === 'PromptInputTextarea') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check if child.type is defined once at the top?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored the code and created separate helper for type checking logic

{textarea}
{overlay}
{actions}
{React.Children.map(children, child => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts here:

  • We do something similar above, so we can move type checking logic to a separate helper, wyt?
  • Are we doing this to make sure the components that are not textarea, overlay, and actions will go after these three?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Refactored the code and created separate helper for type checking logic
  • Yes, the first 3 components should be rendered first before the other children because it affects the positioning of the text when it will be displayed by the overlay.

}
}, [text])

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some short comments to all useEffect hooks in this component?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to move all those useEffects to a separate hook?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments to the useEffect but did not move into a separate hook since it's only being used by this component.

overlay.style.position = 'absolute'
overlay.style.top = paddingTop
overlay.style.left = paddingLeft
overlay.style.width = 'calc(100% - ' + (parseInt(paddingLeft) * 2) + 'px)'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use template string here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored code to use template string.

{paragraphs.map((paragraph, index) => (
<p
key={index}
className={`ds-prompt-input__text-reveal-paragraph ${
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use classnames?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored code to use classnames

@clowreed clowreed merged commit 91c0f81 into main Apr 24, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants