Unverified Commit d0da3cd7 authored by Douglas Gubert's avatar Douglas Gubert Committed by GitHub
Browse files

fix: Section with Overflow visibility (#138)

parent cf9da5f6
import React, { useRef } from 'react';
import React, { useRef, useCallback } from 'react';
import {
AnimatedVisibility,
Button,
PositionAnimated,
Options,
......@@ -15,12 +14,19 @@ const convertOptions = (options, parser) => options.map(({ text, value }) => [va
export const Overflow = ({ context, options, parser, ...element }) => {
const [{ loading }, action] = useBlockContext(element, context);
const handleSelection = ([value]) => action({ target: { value } });
const fireChange = ([value]) => action({ target: { value } });
const convertedOptions = convertOptions(options, parser.text);
const [cursor, handleKeyDown, handleKeyUp, , [visible, hide, show]] = useCursor(-1, convertedOptions, (args, [, hide]) => {
handleSelection(args);
const [cursor, handleKeyDown, handleKeyUp, reset, [visible, hide, show]] = useCursor(-1, convertedOptions, (args, [, hide]) => {
fireChange(args);
reset();
hide();
});
const handleSelection = useCallback((...args) => {
fireChange(...args);
reset();
hide();
}, []);
const ref = useRef();
return (
<>
......@@ -37,7 +43,7 @@ export const Overflow = ({ context, options, parser, ...element }) => {
</Button>
<PositionAnimated
width='auto'
visible={visible ? AnimatedVisibility.VISIBLE : AnimatedVisibility.HIDDEN}
visible={visible}
anchor={ref}
placement='bottom right'
>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment