-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX Don't change scroll position when loading (#171)
- Loading branch information
1 parent
bd31e3a
commit f7fd63a
Showing
9 changed files
with
144 additions
and
65 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
.link-field__save-record-first { | ||
padding-top: 7px; | ||
.link-field__container { | ||
// Gives an anchor point for the loading elements, which is necessary for | ||
// it to work nicely between breakpoints | ||
position: relative; | ||
} | ||
|
||
// Needed to avoid the loading overlay expanding beyond the width of the actual field holder | ||
.link-field__loading { | ||
.cms-content-loading-spinner { | ||
position: initial; | ||
} | ||
.ui-widget-overlay-light { | ||
opacity: 0; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
|
||
.cms-content-loading-overlay { | ||
position: relative; | ||
} | ||
} | ||
|
||
.link-field__save-record-first { | ||
padding-top: 7px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 32 additions & 13 deletions
45
client/src/components/LinkPicker/tests/LinkPicker-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,58 @@ | ||
/* global jest, test */ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { render, fireEvent, act } from '@testing-library/react'; | ||
import { LinkFieldContext } from 'components/LinkField/LinkField'; | ||
import LinkPicker from '../LinkPicker'; | ||
|
||
function makeProps(obj = {}) { | ||
return { | ||
types: { phone: { key: 'phone', title: 'Phone', icon: 'font-icon-phone' } }, | ||
canCreate: true, | ||
onModalSuccess: () => {}, | ||
onModalClosed: () => {}, | ||
...obj | ||
}; | ||
} | ||
|
||
test('LinkPickerMenu render() should display toggle if can create', () => { | ||
const { container } = render(<LinkPicker {...makeProps({ | ||
canCreate: true | ||
})} | ||
/>); | ||
const { container } = render(<LinkFieldContext.Provider value={{ loading: false }}> | ||
<LinkPicker {...makeProps({ canCreate: true })} /> | ||
</LinkFieldContext.Provider>); | ||
expect(container.querySelectorAll('.link-picker__menu-toggle')).toHaveLength(1); | ||
expect(container.querySelectorAll('.link-picker__cannot-create')).toHaveLength(0); | ||
}); | ||
|
||
test('LinkPickerMenu render() should display cannot create message if cannot create', () => { | ||
const { container } = render(<LinkPicker {...makeProps({ | ||
canCreate: false | ||
})} | ||
/>); | ||
const { container } = render(<LinkFieldContext.Provider value={{ loading: false }}> | ||
<LinkPicker {...makeProps({ canCreate: false })} /> | ||
</LinkFieldContext.Provider>); | ||
expect(container.querySelectorAll('.link-picker__menu-toggle')).toHaveLength(0); | ||
expect(container.querySelectorAll('.link-picker__cannot-create')).toHaveLength(1); | ||
}); | ||
|
||
test('LinkPickerMenu render() should display link type icon if can create', () => { | ||
const { container } = render(<LinkPicker {...makeProps({ | ||
canCreate: true | ||
})} | ||
/>); | ||
const { container } = render(<LinkFieldContext.Provider value={{ loading: false }}> | ||
<LinkPicker {...makeProps({ canCreate: true })} /> | ||
</LinkFieldContext.Provider>); | ||
expect(container.querySelectorAll('.link-picker__menu-icon.font-icon-phone')).toHaveLength(1); | ||
}); | ||
|
||
test('LinkPickerMenu should open dropdown on click when not loading', async () => { | ||
const { container } = render(<LinkFieldContext.Provider value={{ loading: false }}> | ||
<LinkPicker {...makeProps()} /> | ||
</LinkFieldContext.Provider>); | ||
await act(async () => { | ||
await fireEvent.click(container.querySelector('button.link-picker__menu-toggle')); | ||
}); | ||
expect(container.querySelectorAll('.dropdown-menu.show')).toHaveLength(1); | ||
}); | ||
|
||
test('LinkPickerMenu should not open dropdown on click while loading', async () => { | ||
const { container } = render(<LinkFieldContext.Provider value={{ loading: true }}> | ||
<LinkPicker {...makeProps()} /> | ||
</LinkFieldContext.Provider>); | ||
await act(async () => { | ||
await fireEvent.click(container.querySelector('button.link-picker__menu-toggle')); | ||
}); | ||
expect(container.querySelectorAll('.dropdown-menu.show')).toHaveLength(0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters