Skip to content

Commit

Permalink
fix(plate): check is click inside component, popover issue
Browse files Browse the repository at this point in the history
  • Loading branch information
reme3d2y committed Aug 23, 2021
1 parent 436fdc0 commit bea8a7d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/plate/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,18 @@ export const Plate = forwardRef<HTMLDivElement, PlateProps>(

const handleClick = useCallback(
event => {
const eventInsideComponent =
plateRef.current && plateRef.current.contains(event.target);

const eventInsideContent =
contentRef.current && contentRef.current.contains(event.target);

const clickSimilarKeys = ['Enter', ' '].includes(event.key);

const shouldChangeIsFolded =
!eventInsideContent && (event.type === 'click' || clickSimilarKeys);
eventInsideComponent &&
!eventInsideContent &&
(event.type === 'click' || clickSimilarKeys);

if (foldable && shouldChangeIsFolded) {
if (uncontrolled) {
Expand Down

0 comments on commit bea8a7d

Please sign in to comment.