Skip to content
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

chore(web): Fix story block creation and preview #837

Merged
merged 11 commits into from
Nov 28, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ export default ({
if (target) {
target.style.pointerEvents = "initial";
setTarget(null);
setIsPause(false);
}
}, [target]);

Expand Down Expand Up @@ -272,6 +271,7 @@ export default ({
},
[inEditor, range, committer?.id, handleOnDrag],
);

const handleTimelineCommitterChange = useCallback(
(committer: TimelineCommitter) => {
if (
Expand All @@ -281,14 +281,14 @@ export default ({
) {
setActiveBlock(" ");
setIsActive(false);
setIsPause(false);
setIsPlaying(false);
setIsPlayingReversed(false);
const currentTimeValue = timelineValues?.currentTime ?? "";
timelineValues
? setCurrentTime?.(getNewDate(new Date(currentTimeValue.substring(0, 19))).getTime())
: setCurrentTime?.(range?.start);
}
setIsPause(false);
},
[activeBlock, isActive, range, setCurrentTime, timelineValues],
);
Expand Down Expand Up @@ -318,7 +318,8 @@ export default ({
]);

useEffect(() => {
if (isActive) onTick?.(handleTick), onCommit?.(handleTimelineCommitterChange);
if (isActive) onTick?.(handleTick);
onCommit?.(handleTimelineCommitterChange);
return () => {
removeTickEventListener?.(handleTick);
removeOnCommitEventListener?.(handleTimelineCommitterChange);
Expand All @@ -345,7 +346,6 @@ export default ({
positionPercentage = Math.round(positionPercentage);
positionPercentage = Math.max(positionPercentage, 16);
positionPercentage = Math.min(positionPercentage, 372);

return positionPercentage;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default ({
const title = useMemo(() => name ?? property?.title, [name, property?.title]);

const handleBlockDoubleClick = useCallback(() => {
onBlockDoubleClick?.(), setEditMode(true);
}, [onBlockDoubleClick]);
if (isEditable) onBlockDoubleClick?.(), setEditMode(true);
}, [isEditable, onBlockDoubleClick]);

const [handleSingleClick, handleDoubleClick] = useDoubleClick(
() => onClick?.(),
Expand Down
2 changes: 1 addition & 1 deletion web/src/beta/lib/core/StoryPanel/Page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const StoryPanel: React.FC<Props> = ({
openBlocks={openBlocksIndex === -1}
installableStoryBlocks={installableStoryBlocks}
onBlockOpen={() => handleBlockOpen(-1)}
onBlockAdd={() => handleBlockCreate(0)}
onBlockAdd={handleBlockCreate(0)}
/>
)}
</PageTitleWrapper>
Expand Down
Loading