Skip to content

Commit

Permalink
Mobile: Avoid adding empty link to text. (#14270)
Browse files Browse the repository at this point in the history
* Mobile Links UI: Avoid creating link with empty url field

* Mobile Links UI: Using URL Keyboard type for url field

* Fix lint issues
  • Loading branch information
etoledom committed Mar 7, 2019
1 parent 2a41903 commit eb59a11
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
7 changes: 0 additions & 7 deletions packages/block-library/src/heading/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@ import { createBlock } from '@wordpress/blocks';

const name = 'core/heading';

/**
* Internal dependencies
*/
import styles from './style.scss';

class HeadingEdit extends Component {
constructor( props ) {
super( props );

this.splitBlock = this.splitBlock.bind( this );
}


/**
* Split handler for RichText value, namely when content is pasted or the
* user presses the Enter key.
Expand Down Expand Up @@ -79,7 +73,6 @@ class HeadingEdit extends Component {
attributes,
setAttributes,
mergeBlocks,
insertBlocksAfter,
style,
} = this.props;

Expand Down
4 changes: 2 additions & 2 deletions packages/editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ export class RichText extends Component {
getRecord() {
const { formatPlaceholder, start, end } = this.state;

var value = this.props.value === undefined ? null : this.props.value;
let value = this.props.value === undefined ? null : this.props.value;

// Since we get the text selection from Aztec we need to be in sync with the HTML `value`
// Removing leading white spaces using `trim()` should make sure this is the case.
if (typeof value === 'string' || value instanceof String) {
if ( typeof value === 'string' || value instanceof String ) {
value = value.trimLeft();
}

Expand Down
13 changes: 11 additions & 2 deletions packages/format-library/src/link/modal.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ModalLinkUI extends Component {
this.onChangeText = this.onChangeText.bind( this );
this.onChangeOpensInNewWindow = this.onChangeOpensInNewWindow.bind( this );
this.removeLink = this.removeLink.bind( this );
this.onDismiss = this.onDismiss.bind( this );

this.state = {
inputValue: '',
Expand Down Expand Up @@ -109,13 +110,21 @@ class ModalLinkUI extends Component {
this.props.onClose();
}

onDismiss() {
if ( this.state.inputValue === '' ) {
this.removeLink();
} else {
this.submitLink();
}
}

render() {
const { isVisible } = this.props;

return (
<BottomSheet
isVisible={ isVisible }
onClose={ this.submitLink }
onClose={ this.onDismiss }
hideHeader
>
{ /* eslint-disable jsx-a11y/no-autofocus */
Expand All @@ -126,7 +135,7 @@ class ModalLinkUI extends Component {
placeholder={ __( 'Add URL' ) }
autoCapitalize="none"
autoCorrect={ false }
textContentType="URL"
keyboardType="url"
onChangeValue={ this.onChangeInputValue }
autoFocus={ Platform.OS === 'ios' }
/>
Expand Down

0 comments on commit eb59a11

Please sign in to comment.