Skip to content

Commit

Permalink
feat(boxai-sidebar): Additional UI fixes (#3923)
Browse files Browse the repository at this point in the history
* feat(boxai-sidebar): Additional UI fixes

* feat(boxai-sidebar): Additional UI fixes
  • Loading branch information
DanilaRubleuski authored Feb 12, 2025
1 parent 2392641 commit 4c0116f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/elements/content-sidebar/BoxAISidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $agentSelectorSidebarWidth: 211px;
}

.bcs-content-header {
margin: 0 tokens.$space-4;
padding: 0 tokens.$space-4;
}

.bcs-scroll-content {
Expand Down
14 changes: 0 additions & 14 deletions src/elements/content-sidebar/BoxAISidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,6 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
questionsWithoutInProgress = questionsWithoutInProgress.slice(0, -1);
}

const handleKeyPress = React.useCallback((event: KeyboardEvent) => {
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
event.preventDefault();
event.stopPropagation();
}
}, []);

React.useEffect(() => {
document.addEventListener('keydown', handleKeyPress, { capture: true });
return () => {
document.removeEventListener('keydown', handleKeyPress, { capture: true });
};
}, [handleKeyPress]);

const localizedQuestions = DOCUMENT_SUGGESTED_QUESTIONS.map(question => ({
id: question.id,
label: formatMessage(messages[question.labelId]),
Expand Down
2 changes: 1 addition & 1 deletion src/elements/content-sidebar/BoxAISidebarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useIntl } from 'react-intl';
import classNames from 'classnames';
import { AgentsProvider, BoxAiAgentSelectorWithApi } from '@box/box-ai-agent-selector';
import { IconButton, Tooltip } from '@box/blueprint-web';
import { ArrowsExpand } from '@box/blueprint-web-assets/icons/Line';
import { ArrowsExpand } from '@box/blueprint-web-assets/icons/Fill';
import {
BoxAiContentAnswers,
ClearConversationButton,
Expand Down
4 changes: 2 additions & 2 deletions src/elements/content-sidebar/SidebarContent.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ $sidebarScrollContentIncreasedWidth: $sidebarScrollContentWidth + 40px;
align-items: center;
justify-content: space-between;
height: $sidebarHeaderHeight;
margin: 0 $sidebarActivityFeedSpacingHorizontal;
padding: 0;
margin: 0;
padding: 0 $sidebarActivityFeedSpacingHorizontal;
border-bottom: 1px solid $bdl-gray-10;

.bcs-title {
Expand Down
12 changes: 6 additions & 6 deletions src/elements/content-sidebar/SidebarNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { injectIntl } from 'react-intl';
import type { IntlShape } from 'react-intl';
import noop from 'lodash/noop';
import { BoxAiLogo } from '@box/blueprint-web-assets/icons/Logo';
import { Size5 } from '@box/blueprint-web-assets/tokens/tokens';
import { Size6 } from '@box/blueprint-web-assets/tokens/tokens';
import AdditionalTabs from './additional-tabs';
import DocGenIcon from '../../icon/fill/DocGenIcon';
import IconChatRound from '../../icons/general/IconChatRound';
Expand Down Expand Up @@ -93,7 +93,7 @@ const SidebarNav = ({
: intl.formatMessage(messages.sidebarBoxAITitle)
}
>
<BoxAiLogo height={Size5} width={Size5} />
<BoxAiLogo height={Size6} width={Size6} />
</SidebarNavButton>
)}
{hasActivity && (
Expand All @@ -105,7 +105,7 @@ const SidebarNav = ({
sidebarView={SIDEBAR_VIEW_ACTIVITY}
tooltip={intl.formatMessage(messages.sidebarActivityTitle)}
>
<IconChatRound />
<IconChatRound className="bcs-SidebarNav-icon" />
</SidebarNavButton>
)}
{hasDetails && (
Expand All @@ -117,7 +117,7 @@ const SidebarNav = ({
sidebarView={SIDEBAR_VIEW_DETAILS}
tooltip={intl.formatMessage(messages.sidebarDetailsTitle)}
>
<IconDocInfo />
<IconDocInfo className="bcs-SidebarNav-icon" />
</SidebarNavButton>
)}
{hasSkills && (
Expand All @@ -129,7 +129,7 @@ const SidebarNav = ({
sidebarView={SIDEBAR_VIEW_SKILLS}
tooltip={intl.formatMessage(messages.sidebarSkillsTitle)}
>
<IconMagicWand />
<IconMagicWand className="bcs-SidebarNav-icon" />
</SidebarNavButton>
)}
{hasMetadata && (
Expand All @@ -141,7 +141,7 @@ const SidebarNav = ({
sidebarView={SIDEBAR_VIEW_METADATA}
tooltip={intl.formatMessage(messages.sidebarMetadataTitle)}
>
<IconMetadataThick />
<IconMetadataThick className="bcs-SidebarNav-icon" />
</SidebarNavButton>
)}
{hasDocGen && (
Expand Down
7 changes: 6 additions & 1 deletion src/elements/content-sidebar/SidebarNav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
}

.bcs-SidebarNav-icon {
@include bdl-SidebarNavIcon;
width: 20px;
height: 20px;

path {
fill: $bdl-gray-65;
}
}

.bcs-SidebarNav-overflow {
Expand Down
24 changes: 0 additions & 24 deletions src/elements/content-sidebar/__tests__/BoxAISidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,28 +247,4 @@ describe('elements/content-sidebar/BoxAISidebar', () => {

expect(screen.queryByTestId('content-answers-modal')).not.toBeInTheDocument();
});

describe('BoxAISidebar handleKeyPress', () => {
test('should prevent default behavior and stop propagation for ArrowLeft and ArrowRight keys', async () => {
await renderComponent();

const eventLeft = new KeyboardEvent('keydown', { key: 'ArrowLeft' });
const preventDefaultSpy = jest.spyOn(eventLeft, 'preventDefault');
const stopPropagationSpy = jest.spyOn(eventLeft, 'stopPropagation');

document.dispatchEvent(eventLeft);

expect(preventDefaultSpy).toHaveBeenCalled();
expect(stopPropagationSpy).toHaveBeenCalled();

const eventRight = new KeyboardEvent('keydown', { key: 'ArrowRight' });
const preventDefaultSpyRight = jest.spyOn(eventRight, 'preventDefault');
const stopPropagationSpyRight = jest.spyOn(eventRight, 'stopPropagation');

document.dispatchEvent(eventRight);

expect(preventDefaultSpyRight).toHaveBeenCalled();
expect(stopPropagationSpyRight).toHaveBeenCalled();
});
});
});

0 comments on commit 4c0116f

Please sign in to comment.