fix: Not able to see all the options of Font property as it is not scrollable + Canvas scroll to top when I drop Tab widget on the canvas (#13608)

* fix tab widget scrolling + text widget font control overflowing issue

* revert text widget changes

* tab widget scroll issue

* remove border radius and box shadow from v1 widgets
This commit is contained in:
Pawan Kumar 2022-05-11 10:23:13 +05:30 committed by GitHub
parent 10aca0297f
commit 2dacdec880
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 86 deletions

View File

@ -610,28 +610,6 @@ class InputWidget extends BaseWidget<InputWidgetProps, WidgetState> {
isTriggerProperty: false, isTriggerProperty: false,
validation: { type: ValidationTypes.TEXT }, validation: { type: ValidationTypes.TEXT },
}, },
{
propertyName: "borderRadius",
label: "Border Radius",
helpText:
"Rounds the corners of the icon button's outer border edge",
controlType: "BORDER_RADIUS_OPTIONS",
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.TEXT },
},
{
propertyName: "boxShadow",
label: "Box Shadow",
helpText:
"Enables you to cast a drop shadow from the frame of the widget",
controlType: "BOX_SHADOW_OPTIONS",
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: { type: ValidationTypes.TEXT },
},
], ],
}, },
]; ];

View File

@ -381,24 +381,6 @@ class MultiSelectWidget extends BaseWidget<
isBindProperty: false, isBindProperty: false,
isTriggerProperty: false, isTriggerProperty: false,
}, },
{
propertyName: "borderRadius",
label: "Border Radius",
helpText:
"Rounds the corners of the icon button's outer border edge",
controlType: "BORDER_RADIUS_OPTIONS",
isBindProperty: false,
isTriggerProperty: false,
},
{
propertyName: "boxShadow",
label: "Box Shadow",
helpText:
"Enables you to cast a drop shadow from the frame of the widget",
controlType: "BOX_SHADOW_OPTIONS",
isBindProperty: false,
isTriggerProperty: false,
},
], ],
}, },
]; ];

View File

@ -121,7 +121,6 @@ function PageTabContainer({
useEffect(() => { useEffect(() => {
if (isTabActive) { if (isTabActive) {
tabContainerRef.current?.scrollIntoView(false);
setShowScrollArrows(); setShowScrollArrows();
} }
}, [isTabActive, tabsScrollable]); }, [isTabActive, tabsScrollable]);

View File

@ -1,7 +1,6 @@
import React, { import React, {
RefObject, RefObject,
ReactNode, ReactNode,
useEffect,
useRef, useRef,
useState, useState,
useCallback, useCallback,
@ -15,7 +14,6 @@ import Icon, { IconSize } from "components/ads/Icon";
import { generateClassName, getCanvasClassName } from "utils/generators"; import { generateClassName, getCanvasClassName } from "utils/generators";
import { Colors } from "constants/Colors"; import { Colors } from "constants/Colors";
import PageTabs from "./PageTabs"; import PageTabs from "./PageTabs";
import useThrottledRAF from "utils/hooks/useThrottledRAF";
interface TabsComponentProps extends ComponentProps { interface TabsComponentProps extends ComponentProps {
children?: ReactNode; children?: ReactNode;
@ -208,9 +206,7 @@ function TabsComponent(props: TabsComponentProps) {
null, null,
); );
const tabsRef = useRef<HTMLElement | null>(null); const tabsRef = useRef<HTMLElement | null>(null);
const [isScrolling, setIsScrolling] = useState(false);
const [tabsScrollable, setTabsScrollable] = useState(false); const [tabsScrollable, setTabsScrollable] = useState(false);
const [isScrollingLeft, setIsScrollingLeft] = useState(false);
const [shouldShowLeftArrow, setShouldShowLeftArrow] = useState(false); const [shouldShowLeftArrow, setShouldShowLeftArrow] = useState(false);
const [shouldShowRightArrow, setShouldShowRightArrow] = useState(true); const [shouldShowRightArrow, setShouldShowRightArrow] = useState(true);
@ -234,36 +230,21 @@ function TabsComponent(props: TabsComponentProps) {
[tabs], [tabs],
); );
const scroll = useCallback(() => { const scroll = useCallback(
const currentOffset = tabsRef.current?.scrollLeft || 0; (isScrollingLeft) => {
const currentOffset = tabsRef.current?.scrollLeft || 0;
if (tabsRef.current) { if (tabsRef.current) {
tabsRef.current.scrollLeft = isScrollingLeft tabsRef.current.scrollLeft = isScrollingLeft
? currentOffset - 5 ? currentOffset - 50
: currentOffset + 5; : currentOffset + 50;
setShowScrollArrows(); setShowScrollArrows();
} }
}, [tabsRef.current, isScrollingLeft]); },
[tabsRef.current],
);
// eslint-disable-next-line // eslint-disable-next-line
const [_intervalRef, _rafRef, requestAF] = useThrottledRAF(scroll, 10); // const [_intervalRef, _rafRef, requestAF] = useThrottledRAF(scroll, 10);
const stopScrolling = () => {
setIsScrolling(false);
setIsScrollingLeft(false);
};
const startScrolling = (isLeft: boolean) => {
setIsScrolling(true);
setIsScrollingLeft(isLeft);
};
useEffect(() => {
let clear;
if (isScrolling) {
clear = requestAF();
}
return clear;
}, [isScrolling, isScrollingLeft]);
// useEffect(() => { // useEffect(() => {
// if (!props.shouldScrollContents) { // if (!props.shouldScrollContents) {
@ -278,14 +259,10 @@ function TabsComponent(props: TabsComponentProps) {
ref={tabContainerRef} ref={tabContainerRef}
> >
{props.shouldShowTabs && ( {props.shouldShowTabs && (
<Container className="relative hidden px-6 h-9 md:flex"> <Container className="relative flex px-6 h-9">
<ScrollBtnContainer <ScrollBtnContainer
className="left-0 scroll-nav-left-button" className="left-0 cursor-pointer scroll-nav-left-button"
onMouseDown={() => startScrolling(true)} onClick={() => scroll(true)}
onMouseLeave={stopScrolling}
onMouseUp={stopScrolling}
onTouchEnd={stopScrolling}
onTouchStart={() => startScrolling(true)}
visible={shouldShowLeftArrow} visible={shouldShowLeftArrow}
> >
<Icon name="left-arrow-2" size={IconSize.MEDIUM} /> <Icon name="left-arrow-2" size={IconSize.MEDIUM} />
@ -299,12 +276,8 @@ function TabsComponent(props: TabsComponentProps) {
tabsScrollable={tabsScrollable} tabsScrollable={tabsScrollable}
/> />
<ScrollBtnContainer <ScrollBtnContainer
className="right-0 scroll-nav-right-button" className="right-0 cursor-pointer scroll-nav-right-button"
onMouseDown={() => startScrolling(false)} onClick={() => scroll(false)}
onMouseLeave={stopScrolling}
onMouseUp={stopScrolling}
onTouchEnd={stopScrolling}
onTouchStart={() => startScrolling(false)}
visible={shouldShowRightArrow} visible={shouldShowRightArrow}
> >
<Icon name="right-arrow-2" size={IconSize.MEDIUM} /> <Icon name="right-arrow-2" size={IconSize.MEDIUM} />