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

Keep the overview open when the article form closes #770

Merged
merged 3 commits into from Jun 5, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 2 additions & 17 deletions client-v2/src/bundles/__tests__/frontsUIBundle.spec.ts
Expand Up @@ -391,33 +391,18 @@ describe('frontsUIBundle', () => {
expect(selectIsFrontOverviewOpen(state, 'front1')).toBe(true);
expect(selectIsFrontOverviewOpen(state, 'front2')).toBe(true);
});
it('should close an overview when a form for that front is opened', () => {
let state = reducer(
{ closedOverviews: [] } as any,
editorOpenOverview('front1')
);
expect(selectIsFrontOverviewOpen(state, 'front1')).toBe(true);
state = reducer(
state.editor,
editorSelectArticleFragment('front1', 'exampleArticleFragment')
);
expect(selectIsFrontOverviewOpen(state, 'front1')).toBe(false);
});
});
describe('Collection item form display', () => {
it('should open and close a collection item form', () => {
let state = reducer(
it('should open a collection item form', () => {
const state = reducer(
undefined,
editorSelectArticleFragment('front1', 'exampleArticleFragment')
);
expect(selectEditorArticleFragment(state, 'front1')).toEqual({
id: 'exampleArticleFragment',
isSupporting: false
});
state = reducer(state.editor, editorOpenOverview('front1'));
expect(selectEditorArticleFragment(state, 'front1')).toBe(undefined);
});
it('should close a collection item form when the overview for that front is opened', () => {});
});
it('should open and close all editing fronts', () => {
const state = reducer(
Expand Down
4 changes: 1 addition & 3 deletions client-v2/src/bundles/frontsUIBundle.ts
Expand Up @@ -491,7 +491,6 @@ const reducer = (state: State = defaultState, action: Action): State => {
case EDITOR_SELECT_ARTICLE_FRAGMENT: {
return {
...state,
closedOverviews: state.closedOverviews.concat(action.payload.frontId),
selectedArticleFragments: {
...state.selectedArticleFragments,
[action.payload.frontId]: {
Expand Down Expand Up @@ -534,13 +533,12 @@ const reducer = (state: State = defaultState, action: Action): State => {
};
}
case EDITOR_OPEN_OVERVIEW: {
const newState = {
return {
...state,
closedOverviews: state.closedOverviews.filter(
id => id !== action.payload.frontId
)
};
return clearArticleFragmentSelection(newState, action.payload.frontId);
}
case EDITOR_CLOSE_OVERVIEW: {
return {
Expand Down
3 changes: 2 additions & 1 deletion client-v2/src/components/FrontsEdit/ArticleFragmentForm.tsx
Expand Up @@ -73,7 +73,8 @@ const FormContainer = styled(ContentContainer.withComponent('form'))`
min-width: ${formMinWidth}px;
max-width: 380px;
margin-left: 10px;
height: 100%;
margin-top: 10px;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A sneaky spacing edit to stop the form abutting the fronts header.

height: calc(100% - 10px);
`;

const FormContent = styled('div')`
Expand Down
6 changes: 3 additions & 3 deletions client-v2/src/components/FrontsEdit/FrontContainer.tsx
Expand Up @@ -67,10 +67,10 @@ const SingleFrontContainer = styled('div')<{
* same width.
*/
min-width: ${({ isOverviewOpen, isFormOpen }) =>
isOverviewOpen
? singleFrontMinWidth + overviewMinWidth + 10
: isFormOpen
isFormOpen
? singleFrontMinWidth + formMinWidth + 10
: isOverviewOpen
? singleFrontMinWidth + overviewMinWidth + 10
: singleFrontMinWidth}px;
flex: 1 1 auto;
height: 100%;
Expand Down