Skip to content

Commit d2660da

Browse files
vidmantaszraphaelpor
authored andcommitted
Text alignment typo fix (#47)
* Text alignment typo fix Text alignment does not work. Wrong key is used. Draft js uses `textAlignment` https://draftjs.org/docs/advanced-topics-text-direction#text-alignment * changing to dot notation * updated tests * fixed linter error
1 parent 0b9aacc commit d2660da

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

sample/__tests__/components/DraftJsText.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ it('extends a style with a customStyle from another type', () => {
7676

7777
it('renders text-align: left', () => {
7878
const text = 'Hello World';
79-
const data = { 'text-align': 'left' };
79+
const data = { textAlignment: 'left' };
8080
const tree = renderer.create(<DraftJsText
8181
type="paragraph"
8282
text={text}
@@ -90,7 +90,7 @@ it('renders text-align: left', () => {
9090

9191
it('renders text-align: right', () => {
9292
const text = 'Hello World';
93-
const data = { 'text-align': 'right' };
93+
const data = { textAlignment: 'right' };
9494
const tree = renderer.create(<DraftJsText
9595
type="paragraph"
9696
text={text}
@@ -104,7 +104,7 @@ it('renders text-align: right', () => {
104104

105105
it('renders text-align: center', () => {
106106
const text = 'Hello World';
107-
const data = { 'text-align': 'center' };
107+
const data = { textAlignment: 'center' };
108108
const tree = renderer.create(<DraftJsText
109109
type="paragraph"
110110
text={text}

src/components/DraftJsText.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const DraftJsText = (props: DraftJsTextPropsType): any => {
3030
});
3131

3232
const customStyle = props.customStyles ? props.customStyles[props.type] : undefined;
33-
const textAlignStyle = { textAlign: props.data['text-align'] };
33+
const textAlignStyle = { textAlign: props.data.textAlignment };
3434

3535
return (
3636
<Text

0 commit comments

Comments
 (0)