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

fix image insert console error #3634

Merged
merged 3 commits into from Nov 27, 2017

Conversation

Projects
None yet
2 participants
@vladanost
Contributor

vladanost commented Nov 23, 2017

Description

Fixes #3633

Editable component is complaining about the caption value type.
On new Image its an empty string and Editable expects an array (caption is registered as type array) or undefined so I set it to undefined if empty string.

I tried setting a default value when registering block type to empty array but that does not work.

caption: {
    type: 'array',
    source: 'children',
    selector: 'figcaption',
    default: [],
},

I would also assume that since caption is registered as type array that default value would be empty array. But I guess it doesn't work that way.

How Has This Been Tested?

Manually tested in the browser.
Current js unit tests pass.

@youknowriad

This comment has been minimized.

Show comment
Hide comment
@youknowriad

youknowriad Nov 24, 2017

Contributor

Thanks for catching this bug,

I investigated a bit and I think the issue we have is elsewhere. When we select an image from the media library, we copy it's caption and it's always a string, we should not copy the caption if it's empty and we should wrap it in an array if it's not empty.

See the onSelectImage function in the image block.

Contributor

youknowriad commented Nov 24, 2017

Thanks for catching this bug,

I investigated a bit and I think the issue we have is elsewhere. When we select an image from the media library, we copy it's caption and it's always a string, we should not copy the caption if it's empty and we should wrap it in an array if it's not empty.

See the onSelectImage function in the image block.

@vladanost

This comment has been minimized.

Show comment
Hide comment
@vladanost

vladanost Nov 24, 2017

Contributor

@youknowriad Thanks. Your suggestion seems to work.

Contributor

vladanost commented Nov 24, 2017

@youknowriad Thanks. Your suggestion seems to work.

@codecov

This comment has been minimized.

Show comment
Hide comment
@codecov

codecov bot Nov 24, 2017

Codecov Report

Merging #3634 into master will decrease coverage by 0.05%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3634      +/-   ##
==========================================
- Coverage   36.95%   36.89%   -0.06%     
==========================================
  Files         268      275       +7     
  Lines        6673     6632      -41     
  Branches     1202     1202              
==========================================
- Hits         2466     2447      -19     
+ Misses       3555     3532      -23     
- Partials      652      653       +1
Impacted Files Coverage Δ
blocks/library/image/block.js 1.72% <0%> (-0.1%) ⬇️
editor/reducer.js 90% <0%> (-0.28%) ⬇️
editor/selectors.js 92.85% <0%> (-0.27%) ⬇️
.../edit-post/sidebar/document-outline-panel/index.js 0% <0%> (ø) ⬆️
editor/edit-post/modes/visual-editor/index.js 0% <0%> (ø) ⬆️
editor/edit-post/layout/index.js 0% <0%> (ø) ⬆️
editor/edit-post/sidebar/post-trash/index.js 0% <0%> (ø) ⬆️
editor/edit-post/header/header-toolbar/index.js 0% <0%> (ø) ⬆️
editor/components/block-list/index.js 0% <0%> (ø) ⬆️
editor/edit-post/header/index.js 0% <0%> (ø) ⬆️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2056a3c...3f0ff9a. Read the comment docs.

codecov bot commented Nov 24, 2017

Codecov Report

Merging #3634 into master will decrease coverage by 0.05%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3634      +/-   ##
==========================================
- Coverage   36.95%   36.89%   -0.06%     
==========================================
  Files         268      275       +7     
  Lines        6673     6632      -41     
  Branches     1202     1202              
==========================================
- Hits         2466     2447      -19     
+ Misses       3555     3532      -23     
- Partials      652      653       +1
Impacted Files Coverage Δ
blocks/library/image/block.js 1.72% <0%> (-0.1%) ⬇️
editor/reducer.js 90% <0%> (-0.28%) ⬇️
editor/selectors.js 92.85% <0%> (-0.27%) ⬇️
.../edit-post/sidebar/document-outline-panel/index.js 0% <0%> (ø) ⬆️
editor/edit-post/modes/visual-editor/index.js 0% <0%> (ø) ⬆️
editor/edit-post/layout/index.js 0% <0%> (ø) ⬆️
editor/edit-post/sidebar/post-trash/index.js 0% <0%> (ø) ⬆️
editor/edit-post/header/header-toolbar/index.js 0% <0%> (ø) ⬆️
editor/components/block-list/index.js 0% <0%> (ø) ⬆️
editor/edit-post/header/index.js 0% <0%> (ø) ⬆️
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2056a3c...3f0ff9a. Read the comment docs.

@youknowriad

Nice Thanks

@youknowriad youknowriad merged commit f51ec08 into WordPress:master Nov 27, 2017

2 checks passed

codecov/project 36.89% (-0.06%) compared to 2056a3c
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment