Skip to content

RNMobile - Image Block: Add caption. (v2) - #10616

Merged
etoledom merged 4 commits into
masterfrom
rnmobile/image-block-caption
Oct 17, 2018
Merged

etoledom merged 4 commits into
masterfrom
rnmobile/image-block-caption

Conversation

@etoledom

Copy link
Copy Markdown
Contributor

Description

This PR adds captions to the mobile version of the Image Block.

caption

To test:

  • Please checkout the gutenberg-mobile project and follow the instructions.

@etoledom

Copy link
Copy Markdown
Contributor Author

Those commits from @mzorz are already on master. Not sure why are appearing again here. 🤔

@hypest

hypest commented Oct 15, 2018

Copy link
Copy Markdown
Contributor

Those commits from @mzorz are already on master. Not sure why are appearing again here. 🤔

Feel free to rebase and force-push this PR @etoledom to make things a bit clearer.

@etoledom
etoledom force-pushed the rnmobile/image-block-caption branch from 2f8977e to c7352c3 Compare October 15, 2018 14:08
@etoledom

Copy link
Copy Markdown
Contributor Author

Thank you @hypest ! I believe now it's ready for review.

if ( isSelected ) {
return textContainer( textInput );
}
return textContainer( text );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason we fall back to plain textview instead of just letting the editing component in?

@etoledom etoledom Oct 15, 2018 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using the editable={ isSelected } property on TextInput. It had these issues:

When the block is not selected, with a caption written, and I tap over it to select the block:

  • IOS: The tap is consumed by the TextInput component and it doesn't select the block.
  • Android: That property seems to not work and it starts editing the caption anyway, without actually selecting the block.

I tested this approach of using the Text component and it worked as expected, so I decided to keep it. If there's a better way I'll be happy to test it!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think the focus/selection issues are already there for the rest of the blocks anyway and we will probably tackle them in unison.

Besides, the textview only solution "solves" the tap-to-focus-block but needs an extra tap to place the cursor.

I think leaving the TextInput (or RichText as the web side does) should be fine for this iteration and should simplify the PR diff for now. WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!
And yes! it will get quite a lot simpler. 😁

…ption.

Now it uses just TextInput in both selected and not-selected state to simplify implementation.
);
}

const CaptionTextInput = ( setAttributes, caption, isSelected ) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point it seems that CaptionTextInput just checks for caption presence/length besides rendering the caption elements. WDYT about copying what the web-side does and just check and inline the JSX snippet directly, like this? This will bring us closer to the web-side and will be easier to compare what's different on the mobile.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that is more declarative in this way, but I agree on trying to be closer to the web-side! I'll push a commit with the change 👍

@hypest hypest left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hypest hypest added the Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) label Oct 16, 2018
@etoledom
etoledom merged commit c7dc7a9 into master Oct 17, 2018
@etoledom
etoledom deleted the rnmobile/image-block-caption branch October 17, 2018 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants