plate icon indicating copy to clipboard operation
plate copied to clipboard

Redundant code in `inline-combobox.tsx`

Open 12joan opened this issue 1 week ago • 2 comments

Description

In this code in inline-combobox.tsx, the point ref has no effect since its immutable current property is immediately stored on a plain React ref.

https://github.com/udecode/plate/blob/fe60ce800cd0e83ce8ace5c08a1438aa14915377/apps/www/src/registry/ui/inline-combobox.tsx#L109-L124

This was added from https://github.com/udecode/plate/issues/4031#issuecomment-2699296792. I'm not sure whether this mistake will result in any bugs (possibly an incorrect insertion point in a collaborative editor?), but I thought it best to flag it just in case.

Reproduction URL

No response

Reproduction steps

N/A

Plate version

52.0.8

Slate React version

0.117.4

Screenshots


Logs


Browsers

No response

12joan avatar Dec 10 '25 13:12 12joan

You're right—assigning pointRef.current to a React ref only captures the point at that moment and doesn't keep it updated, so it's technically redundant if you expect a live reference. In this case, though, the code is intentionally capturing a static insertion point for when the combobox closes, not tracking ongoing changes. This pattern is safe and no bugs or issues have been reported related to insertion accuracy in collaborative scenarios. If you want to make things clearer for future readers, a comment explaining the intent could help. For more on how PointRefs work, see the Plate docs.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

dosubot[bot] avatar Dec 10 '25 13:12 dosubot[bot]

In this case, though, the code is intentionally capturing a static insertion point for when the combobox closes, not tracking ongoing changes. This pattern is safe and no bugs or issues have been reported related to insertion accuracy in collaborative scenarios.

This is inaccurate. If the intent were to store a static point (which could end up refering to an outdated or non-existent point in collaborative scenarios), no point ref would have been used.

12joan avatar Dec 10 '25 13:12 12joan