-
Notifications
You must be signed in to change notification settings - Fork 143
[CLNP-5549] fix: Improve message layout direction hook reliability #1242
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
Conversation
✅ Deploy Preview for sendbird-uikit-react ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
I have a question. Is the reason we need to manipulate the DOM directly because there isn't a top-level component to specify the direction? If that's not the case, wouldn't it be better to cover it using inline styles or classnames to align with the React lifecycle? |
|
@bang9 Thanks for the question. The direct DOM manipulation using
This approach(while not typically React-like..) is the most effective solution for our specific use case of handling bidirectional text support in the message layout with the RTL plugin we're currently using. Not sure this can be a proper answer on your question but let me know if you have any other thoughts :) |
|
Ah, so dir is provided as an element attribute, not a style property. I understand that there isn’t a single DOM element to set a global dir for the entire app. However, I think it might be a bit different in the case of the message container. As far as I know, setting dir on an element propagates to all child elements, so if we set dir on the message container itself, the messages within (as child elements) should automatically adjust their alignment. How about testing this approach? export const MessageList = () => {
// ...
return (
<div dir={forceLeftToRightMessageLayout ? 'ltr' : ''} className={`sendbird-conversation__messages ${className}`}>
<InfiniteList
// ...
/>
</div>
)
} |
chrisallo
left a comment
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!
|
@bang9 Thanks for the suggestion! You're right. I've tested your approach and it's able to solve the problem without regressions. If |
Aim to fix https://sendbird.atlassian.net/browse/SBISSUE-17616
Description
Fixed an issue where the
dirattribute was not being properly applied to message containers. Instead of using DOM manipulation throughuseMessageLayoutDirectionhook, implemented a more React-friendly solution by directly setting thedirattribute on the message container component.Changes
useMessageLayoutDirectionhookMessageListcomponent to directly handle text direction through thedirattributeTesting
Please test the following scenarios:
forceLeftToRightMessageLayout/hTMLTextDirectionNote
This change simplifies our approach to handling text direction while maintaining full compatibility with our RTL support system.
Checklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If unsure, ask the members.This is a reminder of what we look for before merging your code.
External Contributions
This project is not yet set up to accept pull requests from external contributors.
If you have a pull request that you believe should be accepted, please contact
the Developer Relations team [email protected] with details
and we'll evaluate if we can set up a CLA to allow for the contribution.