Skip to content

Commit

Permalink
fix(collapsible): update tooltip over toggle panel button
Browse files Browse the repository at this point in the history
  • Loading branch information
Satyam Chatterjee committed Aug 2, 2023
1 parent acfbf4d commit 79faecb
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 44 deletions.
36 changes: 25 additions & 11 deletions core/components/atoms/collapsible/Collapsible.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import classNames from 'classnames';
import { Icon } from '@/index';
import { Icon, Tooltip, Divider } from '@/index';
import { BaseProps, extractBaseProps } from '@/utils/types';

export interface CollapsibleProps extends BaseProps {
Expand Down Expand Up @@ -44,9 +44,9 @@ export const Collapsible = (props: CollapsibleProps) => {
const baseProps = extractBaseProps(props);

React.useEffect(() => {
if (ref.current) {
setSeperator(ref.current.scrollHeight > ref.current.clientHeight);
}
window.requestAnimationFrame(() => {
ref.current && setSeperator(ref.current.scrollHeight > ref.current.clientHeight);
});
});

const WrapperClass = classNames({
Expand All @@ -70,7 +70,6 @@ export const Collapsible = (props: CollapsibleProps) => {

const FooterClass = classNames({
['Collapsible-footer']: true,
['Collapsible-footer--seperator']: seperator,
});

const onToggleHandler = (newExpanded: boolean, type: string) => () => {
Expand Down Expand Up @@ -102,6 +101,7 @@ export const Collapsible = (props: CollapsibleProps) => {
>
{children}
</div>
{withTrigger && seperator && <Divider appearance="header" />}
{withTrigger && (
<div
role="button"
Expand All @@ -111,12 +111,26 @@ export const Collapsible = (props: CollapsibleProps) => {
onClick={onToggleHandler(!expanded, 'click')}
onKeyDown={onToggleHandler(!expanded, 'click')}
>
<Icon
name={expanded ? 'keyboard_arrow_left' : 'keyboard_arrow_right'}
data-test="DesignSystem-Collapsible--FooterIcon"
className="px-6 py-4 my-2 cursor-pointer"
size={16}
/>
{expanded && (
<Tooltip tooltip="Collapse the panel" position="right">
<Icon
name="keyboard_arrow_left"
data-test="DesignSystem-Collapsible--FooterIcon"
className="px-6 py-4 my-2 cursor-pointer"
size={16}
/>
</Tooltip>
)}
{!expanded && (
<Tooltip tooltip="Expand the panel" position="right">
<Icon
name="keyboard_arrow_right"
data-test="DesignSystem-Collapsible--FooterIcon"
className="px-6 py-4 my-2 cursor-pointer"
size={16}
/>
</Tooltip>
)}
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ exports[`Collapsible component
role="button"
tabindex="0"
>
<i
class="material-icons material-icons-round Icon px-6 py-4 my-2 cursor-pointer"
data-test="DesignSystem-Collapsible--FooterIcon"
role="button"
style="font-size: 16px; width: 16px;"
<style />
<div
class="OutsideClick PopperWrapper-trigger"
>
keyboard_arrow_right_round
</i>
<i
class="material-icons material-icons-round Icon px-6 py-4 my-2 cursor-pointer"
data-test="DesignSystem-Collapsible--FooterIcon"
role="button"
style="font-size: 16px; width: 16px;"
>
keyboard_arrow_right_round
</i>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -73,14 +78,19 @@ exports[`Collapsible component
role="button"
tabindex="0"
>
<i
class="material-icons material-icons-round Icon px-6 py-4 my-2 cursor-pointer"
data-test="DesignSystem-Collapsible--FooterIcon"
role="button"
style="font-size: 16px; width: 16px;"
<style />
<div
class="OutsideClick PopperWrapper-trigger"
>
keyboard_arrow_right_round
</i>
<i
class="material-icons material-icons-round Icon px-6 py-4 my-2 cursor-pointer"
data-test="DesignSystem-Collapsible--FooterIcon"
role="button"
style="font-size: 16px; width: 16px;"
>
keyboard_arrow_right_round
</i>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -118,14 +128,19 @@ exports[`Collapsible component
role="button"
tabindex="0"
>
<i
class="material-icons material-icons-round Icon px-6 py-4 my-2 cursor-pointer"
data-test="DesignSystem-Collapsible--FooterIcon"
role="button"
style="font-size: 16px; width: 16px;"
<style />
<div
class="OutsideClick PopperWrapper-trigger"
>
keyboard_arrow_left_round
</i>
<i
class="material-icons material-icons-round Icon px-6 py-4 my-2 cursor-pointer"
data-test="DesignSystem-Collapsible--FooterIcon"
role="button"
style="font-size: 16px; width: 16px;"
>
keyboard_arrow_left_round
</i>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -163,14 +178,19 @@ exports[`Collapsible component
role="button"
tabindex="0"
>
<i
class="material-icons material-icons-round Icon px-6 py-4 my-2 cursor-pointer"
data-test="DesignSystem-Collapsible--FooterIcon"
role="button"
style="font-size: 16px; width: 16px;"
<style />
<div
class="OutsideClick PopperWrapper-trigger"
>
keyboard_arrow_left_round
</i>
<i
class="material-icons material-icons-round Icon px-6 py-4 my-2 cursor-pointer"
data-test="DesignSystem-Collapsible--FooterIcon"
role="button"
style="font-size: 16px; width: 16px;"
>
keyboard_arrow_left_round
</i>
</div>
</div>
</div>
</div>
Expand Down
5 changes: 0 additions & 5 deletions css/src/components/collapsible.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
.Collapsible-footer {
padding-top: var(--spacing-m);
padding-bottom: var(--spacing-m);
box-sizing: border-box;
cursor: pointer;
display: flex;
}
Expand All @@ -53,7 +52,3 @@
.Collapsible-footer:active {
background-color: var(--secondary-light);
}

.Collapsible-footer--seperator {
border-top: var(--spacing-xs) solid var(--secondary-light);
}

0 comments on commit 79faecb

Please sign in to comment.