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

[RNMobile] Extend current Button settings with automatically pasting link #20462

Merged
merged 3 commits into from
Feb 27, 2020
Merged
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
19 changes: 12 additions & 7 deletions packages/block-library/src/button/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ class ButtonEdit extends Component {
} = this.props;
const { isLinkSheetVisible, isButtonFocused } = this.state;

// Get initial value for `isEditingURL` when closing link settings sheet or button settings sheet
if (
( prevProps.editorSidebarOpened && ! editorSidebarOpened ) ||
( prevState.isLinkSheetVisible && ! isLinkSheetVisible )
) {
// Prepends "http://" to an url when closing link settings sheet and button settings sheet
setAttributes( { url: prependHTTP( url ) } );
// Get initial value for `isEditingURL` when closing link settings sheet or button settings sheet
this.isEditingURL = false;
}

Expand All @@ -102,15 +104,14 @@ class ButtonEdit extends Component {
}

// Paste a URL from clipboard
if ( isLinkSheetVisible && ! url && ! this.isEditingURL ) {
if (
( isLinkSheetVisible || editorSidebarOpened ) &&
! url &&
! this.isEditingURL
) {
this.getURLFromClipboard();
}

// Prepends "http://" to a url when closing link settings sheet and button settings sheet
if ( ! isLinkSheetVisible && ! editorSidebarOpened ) {
setAttributes( { url: prependHTTP( url ) } );
}

if ( this.richTextRef ) {
const selectedRichText = this.richTextRef.props.id === selectedId;

Expand Down Expand Up @@ -238,6 +239,10 @@ class ButtonEdit extends Component {
onChange={ this.onChangeURL }
autoCapitalize="none"
autoCorrect={ false }
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={
! isCompatibleWithSettings && Platform.OS === 'ios'
}
separatorType={
isCompatibleWithSettings ? 'fullWidth' : 'leftMargin'
}
Expand Down