Skip to content
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

Add border on Title when focused #622

Merged
merged 18 commits into from
Feb 21, 2019
Merged

Add border on Title when focused #622

merged 18 commits into from
Feb 21, 2019

Conversation

pinarol
Copy link
Contributor

@pinarol pinarol commented Feb 20, 2019

Fix #540
Fix #551

This change adds borders to the Title when focused in order to match other blocks.
And also fixes a slight shift happening on Android when we focus to a block.

gutenberg PR needs to be merged first: WordPress/gutenberg#13970

android-title-border

ios-title-border

To Test

Testing prerequisites

For WPiOS

Checkout the PRs branch to any arbitrary folder and cd .. to it
run yarn install, yarn start
Open XCode WPiOS on the latest develop
Clean build folder on Xcode, and then run the app

For WPAndroid

open grade.properties at WordPress-Android folder
add wp.BUILD_GUTENBERG_FROM_SOURCE = true to grade.properties
checkout the PRs branch in the subrepo of WordPress-Android repo
cd to WordPress-Android/libs/gutenberg-mobile
run yarn install, yarn start
yarn wpandroid on a separate terminal in the same directory

Test Steps:

WPiOS:

  • Open a post and tap the title
  • Verify you see focus indicating borders around the title just like the other blocks
  • Verify there's no slight shifting on portrait mode when we focus on a block because there should be no left right borders

iPhone X and iPad special case:

  • Verify that you do see the left right borders when there's empty space around the block like there's on iPhone X landscape mode, and iPad portrait and landscape modes.

WPAndroid:

}

.blockHolderFocusedSemiBordered {
border-color: $gray-lighten-30;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to use css box-shadow to apply these focus states? In theory that should prevent any shifting, just applying a shadow on the outside edge of the element.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately box-shadow property is not available in React Native and as I investigated it is not a very straight forward change to replace borders with shadows in RN. Because Android and iOS have very different methods for doing it and both methods have different side effects that needs to be addressed.

iOS has these props:
https://facebook.github.io/react-native/docs/shadow-props#shadowcolor

Android has the elevation option but there are no other options to fine-tune the shadow effect. So I am not even sure it'll give the results we want.
https://facebook.github.io/react-native/docs/view-style-props#elevation

I tried to apply these quickly but it messed up the child views' styles in different ways, so it didn't look like an ideal last minute change, but, if you want we can open a separate issue for this and try later?

In this PR, I fixed the shifting of Android blocks. I don't expect any shifting will happen in cases where the block width is equal to window width, because in that case we don't have left&right borders at all.

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

@pinarol - Code looks good! ✨
Just left a small comment there.

The title borders works well and the Android issue with horizontal borders is gone! 🎉

I did find a small issue with the title autofocus in both WPiOS and WPAndroid:

The title borders weren't added when the title was initially focused (opening an empty new post), but after tapping on the title, the borders would appear.

Let me know if you can't reproduce this issue.

Thanks for wrangling this!

src/block-management/block-manager.js Outdated Show resolved Hide resolved
@pinarol
Copy link
Contributor Author

pinarol commented Feb 21, 2019

@etoledom 👋 thanks for the review. I am going to address that issue about the empty post but before that I found another issue unfortunately, it looks a bit annoying and still couldn't come up with a solution. On Android, the title focus is getting lost in the first tap:

android-title-focus-lost-on-first-tap

I am guessing the re-render of the title view in order to add the borders might be somehow triggering a blur event on Android side, I've seen the blur event coming from Android side but not sure about the root cause of it. This is not happening on iOS. Still looking into it.

@etoledom etoledom self-requested a review February 21, 2019 07:41
# Conflicts:
#	gutenberg
#	src/block-management/block-manager.js
…/gutenberg-mobile into issue/540-title-borders
Also border styling mechanism changes, we start just to play with border colors in order to provide smoother animation
This also solves Android's re-render title issue on the first tap
@pinarol
Copy link
Contributor Author

pinarol commented Feb 21, 2019

Hey @etoledom 👋 This is ready for another look.

It looks like Android can somehow re-render the title if we add border to it and this makes a blur event get triggered. So I changed the way we add borders, I updated the container views with borders of transparent color. When we focus I just change the border color. So we will not only get rid of unnecessary re-renders but also we are removing possibilities of the shifting effects when we focus. This is how the shadow effect would work also, cc @iamthomasbishop

ios-title-focus-landscape

android-titlefocus

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

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

Commented on WordPress/gutenberg#13970 (review)

cmd+c cmd+p:

@pinarol - This feels so much better! Great idea ✨

Also the code looks better organized and clean.
The issues mentioned before are gone and borders in general just work great.

I left a couple of small comments but I'm happy to ✅ and :shipit:

placeholder={ __( 'Add title' ) } />
</View>
<PostTitle
onRef={ ( ref ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Can we name this ref instead of onRef? Since it seems to be more standard in React.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done with 67b509a

@pinarol pinarol merged commit 224a4a1 into develop Feb 21, 2019
@pinarol pinarol deleted the issue/540-title-borders branch February 21, 2019 17:17
daniloercoli added a commit that referenced this pull request Feb 22, 2019
…rg-mobile into issue/609-Show-Title-block-when-HTML-mode

* 'develop' of https://github.com/wordpress-mobile/gutenberg-mobile: (44 commits)
  Updated bundles
  Add border on Title when focused (#622)
  Default to the device language for the example app
  Updates the gutenberg submodule ref.
  Updates the gutenberg submodule reference.
  Re-add rootTagsToEliminate option to RichText (#636)
  Give priority to the parent app translations
  Remove unnecessary import
  Fix lint issue
  Fallback to a locale without a regional code if not supported
  Add Greek support
  PR got merged upstream so, use upstream
  Run yarn i18n-cache on postinstall
  Run yarn prebundle before bundle:android and bundle:ios instead
  Use a forked+patched jsdom-jscore with normalization fix
  Revert "Update GB ref with fix for node.rel"
  Upload media progress bar is missing while media is uploading new (#631)
  Remove JS handling of title focus
  Update GB ref with fix for node.rel
  Update iOS translation values as arrays
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants