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

Mobile: Avoid adding empty link to text. #14270

Merged
merged 3 commits into from
Mar 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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