Skip to content

Commit

Permalink
fix: Section with Overflow visibility (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-gubert authored Feb 7, 2020
1 parent cf9da5f commit d0da3cd
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/fuselage-ui-kit/src/Overflow.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useRef } from 'react';
import React, { useRef, useCallback } from 'react';
import {
AnimatedVisibility,
Button,
PositionAnimated,
Options,
Expand All @@ -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 (
<>
Expand All @@ -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'
>
Expand Down

0 comments on commit d0da3cd

Please sign in to comment.