Commit fcf1e6ac authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

Render the `NotebookModal` only when `groupId` is defined

On Firefox, I have noticed that the notebook close button is briefly
displayed and then hidden. This delay is probably caused by time that it
takes to parse the CSS until it is applied. To avoid this 'blink' we
render the component only when the `groupId` is set.
parent 1d0e3a32
...@@ -98,6 +98,10 @@ export default function NotebookModal({ eventBus, config }) { ...@@ -98,6 +98,10 @@ export default function NotebookModal({ eventBus, config }) {
emitter.current.publish('closeNotebook'); emitter.current.publish('closeNotebook');
}; };
if (groupId === null) {
return null;
}
return ( return (
<div <div
className={classnames('NotebookModal__outer', { 'is-hidden': isHidden })} className={classnames('NotebookModal__outer', { 'is-hidden': isHidden })}
...@@ -111,9 +115,7 @@ export default function NotebookModal({ eventBus, config }) { ...@@ -111,9 +115,7 @@ export default function NotebookModal({ eventBus, config }) {
variant="dark" variant="dark"
/> />
</div> </div>
{groupId !== null && ( <NotebookIframe key={iframeKey} config={config} groupId={groupId} />
<NotebookIframe key={iframeKey} config={config} groupId={groupId} />
)}
</div> </div>
</div> </div>
); );
......
...@@ -34,15 +34,14 @@ describe('NotebookModal', () => { ...@@ -34,15 +34,14 @@ describe('NotebookModal', () => {
const wrapper = createComponent(); const wrapper = createComponent();
const outer = wrapper.find('.NotebookModal__outer'); const outer = wrapper.find('.NotebookModal__outer');
assert.isTrue(outer.hasClass('is-hidden')); assert.isFalse(outer.exists());
assert.isFalse(wrapper.find('iframe').exists());
}); });
it('shows modal on "openNotebook" event', () => { it('shows modal on "openNotebook" event', () => {
const wrapper = createComponent(); const wrapper = createComponent();
let outer = wrapper.find('.NotebookModal__outer'); let outer = wrapper.find('.NotebookModal__outer');
assert.isTrue(outer.hasClass('is-hidden')); assert.isFalse(outer.exists());
assert.isFalse(wrapper.find('iframe').exists()); assert.isFalse(wrapper.find('iframe').exists());
emitter.publish('openNotebook', 'myGroup'); emitter.publish('openNotebook', 'myGroup');
...@@ -124,6 +123,7 @@ describe('NotebookModal', () => { ...@@ -124,6 +123,7 @@ describe('NotebookModal', () => {
emitter.publish('openNotebook', 'myGroup'); emitter.publish('openNotebook', 'myGroup');
}); });
assert.equal(document.body.style.overflow, 'hidden'); assert.equal(document.body.style.overflow, 'hidden');
wrapper.update();
act(() => { act(() => {
wrapper.find('IconButton').prop('onClick')(); wrapper.find('IconButton').prop('onClick')();
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment