-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Popover: add anchor
prop
#43691
Popover: add anchor
prop
#43691
Changes from all commits
157f8e7
c185f24
76fd3f2
28c7b18
16e66d4
7b62c02
eef3dc6
1866f3f
fb6f2ee
3e59ec1
c19495c
c342d79
c3a3f61
03eb730
33c87f1
d1890ed
044dd4a
f9fbae5
13327ef
a659e87
4db67fc
aadd730
c787c54
0ac5e79
f9a748a
bc75d2f
b4973f4
7a7179f
42a72ac
8c76d7b
d09cbfe
dffc311
dd1b771
24c099a
1d11ed2
caacb0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,7 +328,7 @@ function RichTextWrapper( | |
} | ||
|
||
function onFocus() { | ||
anchorRef.current.focus(); | ||
anchorRef.current?.focus(); | ||
} | ||
|
||
const TagName = tagName; | ||
|
@@ -354,7 +354,7 @@ function RichTextWrapper( | |
{ isSelected && hasFormats && ( | ||
<FormatToolbarContainer | ||
inline={ inlineToolbar } | ||
anchorRef={ anchorRef } | ||
editableContentElement={ anchorRef.current } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think we need to be careful of this case when refactoring. Reading refs during render is not recommended and may throw a warning in the future. I think that's also why I wonder if there's a way to warn against usage like this on the API level 🤔? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is tricky. References were already used prior to this PR (for this specific case, they were read inside the If anything, this PR slightly improves the situation by deprecating the
That's correct, and in fact I tried to refactor as many parts of the code as possible to
I don't think so, at least from the I did add a few paragraphs in the component's README about using internal state in order to ensure reactive updates (74af7eb) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's definitely tricky 🤔, I don't have a solution yet either. I think - anchor={ ref.current }
+ anchor={ () => ref.current } As long as the underlying implementation of But then it all just feels like an attempt to fix a false positive though, I'm not sure if it's worth it 😅. Let's keep it as is until we find a better solution? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agreed. The best way to solve this problem would be to refactor the code outside of the |
||
value={ value } | ||
/> | ||
) } | ||
|
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.
Noting that, compared to
trunk
, this PR is not taking into account the fact that for non-vertical, LTR cases thebottom
was supposed to be different from the top.The assumption is that
bottom
should have been the same astop
(see #41156 (comment))cc @youknowriad