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

Update focus order for search result page #209

Merged
merged 8 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions src/components/pages/SearchResultPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import SearchResultTitleBar from '../search/SearchResultTitleBar';
import SelectBar from '../search/SelectBar';
import ExportModalContainer from '../../containers/search/ExportModalContainer';
import WatchedSearchResultTableContainer from '../../containers/search/WatchedSearchResultTableContainer';
import SearchResultSidebarToggleButtonContainer from '../../containers/search/SearchResultSidebarToggleButtonContainer';
import SearchToRelateModalContainer from '../../containers/search/SearchToRelateModalContainer';
import { canRelate } from '../../helpers/permissionHelpers';
import { getListType } from '../../helpers/searchHelpers';
Expand All @@ -32,7 +31,6 @@ import {

import styles from '../../../styles/cspace-ui/SearchResultPage.css';
import pageBodyStyles from '../../../styles/cspace-ui/PageBody.css';
import sidebarToggleBarStyles from '../../../styles/cspace-ui/SidebarToggleBar.css';

// const stopPropagation = (event) => {
// event.stopPropagation();
Expand Down Expand Up @@ -785,7 +783,6 @@ export default class SearchResultPage extends Component {
} = this.state;

const searchDescriptor = this.getSearchDescriptor();
const advancedSearchCondition = searchDescriptor.getIn(['searchQuery', 'as']);

const listType = this.getListType(searchDescriptor);

Expand Down Expand Up @@ -847,17 +844,6 @@ export default class SearchResultPage extends Component {
searchName={SEARCH_RESULT_PAGE_SEARCH_NAME}
updateDocumentTitle
/>

<div
className={
advancedSearchCondition
? sidebarToggleBarStyles.advanced
: sidebarToggleBarStyles.normal
}
>
<SearchResultSidebarToggleButtonContainer />
</div>

<div className={isSidebarOpen ? pageBodyStyles.common : pageBodyStyles.full}>
<WatchedSearchResultTableContainer
config={config}
Expand Down
20 changes: 19 additions & 1 deletion src/components/search/SearchResultSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import PropTypes from 'prop-types';
import Immutable from 'immutable';
import SearchResultBatchPanelContainer from '../../containers/search/SearchResultBatchPanelContainer';
import SearchResultReportPanelContainer from '../../containers/search/SearchResultReportPanelContainer';
import SearchResultSidebarToggleButtonContainer from '../../containers/search/SearchResultSidebarToggleButtonContainer';
import styles from '../../../styles/cspace-ui/SearchResultSidebar.css';
import sidebarToggleBarStyles from '../../../styles/cspace-ui/SidebarToggleBar.css';

const panelColor = 'black';

Expand All @@ -23,6 +25,14 @@ const defaultProps = {
isOpen: true,
};

function renderSidebarToggle() {
return (
<div className={sidebarToggleBarStyles.common}>
<SearchResultSidebarToggleButtonContainer />
</div>
);
}

export default function SearchResultSidebar(props) {
const {
config,
Expand All @@ -32,12 +42,20 @@ export default function SearchResultSidebar(props) {
selectedItems,
} = props;

const toggle = renderSidebarToggle();

if (!isOpen) {
return null;
return (
<div className={styles.closed}>
{toggle}
</div>
);
}

return (
<div className={styles.common}>
{toggle}

<SearchResultReportPanelContainer
color={panelColor}
config={config}
Expand Down
3 changes: 3 additions & 0 deletions src/components/search/SearchResultTitleBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default function SearchResultTitleBar(props) {
}

let advancedTitle;
let serviceType = 'searchresult';

if (advancedSearchCondition) {
advancedTitle = (
Expand All @@ -106,6 +107,7 @@ export default function SearchResultTitleBar(props) {
recordType={recordType}
/>
);
serviceType = 'advancedsearchresult';
}

const title = (
Expand All @@ -125,6 +127,7 @@ export default function SearchResultTitleBar(props) {
title={title}
aside={aside}
subtitle={advancedTitle}
serviceType={serviceType}
{...remainingProps}
/>
);
Expand Down
4 changes: 4 additions & 0 deletions styles/cspace-ui/SearchResultSidebar.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.common {
width: 30%;
}

.closed {
flex: none;
}
9 changes: 3 additions & 6 deletions styles/cspace-ui/SidebarToggleBar.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
@value tabHeight from '../dimensions.css';

.normal {
height: tabHeight;
}

.advanced {
.common {
height: 0;
position: relative;
}

.advanced > :global(.cspace-ui-SidebarToggleButton--common) {
.common > :global(.cspace-ui-SidebarToggleButton--common) {
top: -31px;
right: 0;
width: max-content;
}
4 changes: 4 additions & 0 deletions styles/cspace-ui/TitleBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
text-align: right;
}

.searchresult {
margin-bottom: 31px;
}

.audit > div > div > aside > h2,
.object > div > div > aside > h2,
.procedure > div > div > aside > h2,
Expand Down
31 changes: 24 additions & 7 deletions test/specs/components/search/SearchResultSidebar.spec.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import React from 'react';
import { createRenderer } from 'react-test-renderer/shallow';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { Provider as StoreProvider } from 'react-redux';
import Immutable from 'immutable';
import { IntlProvider } from 'react-intl';
import createTestContainer from '../../../helpers/createTestContainer';
import { render } from '../../../helpers/renderHelpers';
import SearchResultSidebar from '../../../../src/components/search/SearchResultSidebar';
Expand Down Expand Up @@ -35,15 +40,27 @@ describe('SearchResultSidebar', () => {
result.type.should.equal('div');
});

it('should render nothing if isOpen is false', function test() {
it('should only render the sidebar toggle if isOpen is false', function test() {
const mockStore = configureMockStore([thunk]);
const store = mockStore({
prefs: Immutable.Map({
searchResultSidebarOpen: false,
}),
});

render(
<SearchResultSidebar
config={config}
recordType="group"
isOpen={false}
/>, this.container,
<IntlProvider locale="en">
<StoreProvider store={store}>
<SearchResultSidebar
config={config}
recordType="group"
isOpen={false}
/>
</StoreProvider>
</IntlProvider>, this.container,
);

expect(this.container.firstElementChild).to.equal(null);
expect(this.container.querySelector('.cspace-ui-SearchResultSidebar--common')).to.equal(null);
this.container.querySelector('.cspace-ui-SearchResultSidebar--closed').textContent.should.equal('Show sidebar');
});
});