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] Embed block: Enable replace option #33253

Merged
merged 3 commits into from
Jul 7, 2021
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
1 change: 1 addition & 0 deletions packages/block-library/src/embed/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ const EmbedEdit = ( props ) => {
invalidateResolution( 'getEmbedPreview', [ url ] );
} }
isSelected={ isSelected }
isEditingURL={ isEditingURL }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

isEditingURL is true when the replace action is triggered.

/>
</View>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ const EmbedBottomSheet = ( { value, isVisible, onClose, onSubmit } ) => {
createErrorNotice(
__( 'Invalid URL. Please enter a valid URL.' )
);
// If the URL was already defined, we submit it to stop showing the embed placeholder.
if ( value !== '' ) {
onSubmit( value );
}
}
} else if ( value !== '' ) {
// Resets the URL when new value is empty and URL was already defined.
onSubmit( '' );
}
}, [ url, onSubmit ] );
}, [ url, onSubmit, value ] );

function setAttributes( attributes ) {
setURL( attributes.url );
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/embed/embed-placeholder.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import styles from './styles.scss';

const EmbedPlaceholder = ( {
icon,
isEditingURL,
isSelected,
label,
onFocus,
Expand All @@ -39,7 +40,7 @@ const EmbedPlaceholder = ( {
[ clientId ]
);
const [ isEmbedSheetVisible, setIsEmbedSheetVisible ] = useState(
isSelected && wasBlockJustInserted && ! value
isSelected && ( ( wasBlockJustInserted && ! value ) || isEditingURL )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change enables the bottom sheet to be automatically displayed when the replace action is triggered.

);

const containerStyle = usePreferredColorSchemeStyle(
Expand Down