mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-11-07 15:07:29 +08:00
Summary:
- Fixes bug with Composer focus caused by injected component. The composer body
was being focused, but the cursor remained at the beginning of the content
instead of at the end. This was caused because the focus method was being
called before the content had actually been rendered to the dom.
- Adds a callback to check when injected comp was actually rendered, and uses
that to focus the body at the correct time.
- Updates specs
- Updates behavior of focusing composer body when selecting threads in split
mode -- resolves #T3444
- It will focus the body when a thread is selcted via a click
- It wont focus the body when a thread is selected via arrow keys
- It will focus the body when a new inline reply is created
- Updates specs
Test Plan: - Unit tests
Reviewers: evan, bengotow
Reviewed By: bengotow
Differential Revision: https://phab.nylas.com/D2393
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
import {React, ComponentRegistry, NylasTestUtils} from 'nylas-exports';
|
|
import {InjectedComponentSet} from 'nylas-component-kit';
|
|
const {renderIntoDocument} = NylasTestUtils;
|
|
|
|
const reactStub = (displayName)=> {
|
|
return React.createClass({
|
|
displayName,
|
|
render() { return <div className={displayName}></div>; },
|
|
});
|
|
};
|
|
|
|
|
|
describe('InjectedComponentSet', ()=> {
|
|
describe('render', ()=> {
|
|
beforeEach(()=> {
|
|
const components = [reactStub('comp1'), reactStub('comp2')];
|
|
spyOn(ComponentRegistry, 'findComponentsMatching').andReturn(components);
|
|
});
|
|
|
|
it('calls `onComponentsDidRender` when all child comps have actually been rendered to the dom', ()=> {
|
|
let rendered;
|
|
const onComponentsDidRender = ()=> {
|
|
rendered = true;
|
|
};
|
|
runs(()=> {
|
|
renderIntoDocument(
|
|
<InjectedComponentSet
|
|
matching={{}}
|
|
onComponentsDidRender={onComponentsDidRender} />
|
|
);
|
|
});
|
|
|
|
waitsFor(
|
|
()=> { return rendered; },
|
|
'`onComponentsDidMount` should be called',
|
|
100
|
|
);
|
|
|
|
runs(()=> {
|
|
expect(rendered).toBe(true);
|
|
expect(document.querySelectorAll('.comp1').length).toEqual(1);
|
|
expect(document.querySelectorAll('.comp2').length).toEqual(1);
|
|
});
|
|
});
|
|
});
|
|
});
|