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] Fix ShouldInsertAtTheTop setting calculation #32110

Merged
merged 1 commit into from
May 24, 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
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ function useBlockEditorSettings( settings, hasTemplate ) {
reusableBlocks,
hasUploadPermissions,
canUseUnfilteredHTML,
isTitleSelected,
} = useSelect( ( select ) => {
const { canUserUseUnfilteredHTML, isPostTitleSelected } = select(
editorStore
);
const { canUserUseUnfilteredHTML } = select( editorStore );
const isWeb = Platform.OS === 'web';
const { canUser } = select( coreStore );

Expand All @@ -54,8 +51,6 @@ function useBlockEditorSettings( settings, hasTemplate ) {
canUser( 'create', 'media' ),
true
),
// This selector is only defined on mobile.
isTitleSelected: isPostTitleSelected && isPostTitleSelected(),
};
}, [] );

Expand Down Expand Up @@ -111,7 +106,6 @@ function useBlockEditorSettings( settings, hasTemplate ) {
fetchRemoteUrlData( url ),
__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
__experimentalUndo: undo,
__experimentalShouldInsertAtTheTop: isTitleSelected,
outlineMode: hasTemplate,
} ),
[
Expand All @@ -120,7 +114,6 @@ function useBlockEditorSettings( settings, hasTemplate ) {
reusableBlocks,
canUseUnfilteredHTML,
undo,
isTitleSelected,
hasTemplate,
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import { store as coreStore } from '@wordpress/core-data';
* Internal dependencies
*/
import useBlockEditorSettings from './use-block-editor-settings.js';
import { store as editorStore } from '../../store';

function useNativeBlockEditorSettings( settings, hasTemplate ) {
const capabilities = settings.capabilities ?? {};
const editorSettings = useBlockEditorSettings( settings, hasTemplate );

const supportReusableBlock = capabilities.reusableBlock === true;
const { reusableBlocks } = useSelect(
const { isTitleSelected, reusableBlocks } = useSelect(
( select ) => ( {
reusableBlocks: supportReusableBlock
? select( coreStore ).getEntityRecords(
Expand All @@ -26,6 +27,7 @@ function useNativeBlockEditorSettings( settings, hasTemplate ) {
{ per_page: 100 }
)
: [],
isTitleSelected: select( editorStore ).isPostTitleSelected(),
} ),
[ supportReusableBlock ]
);
Expand All @@ -34,8 +36,9 @@ function useNativeBlockEditorSettings( settings, hasTemplate ) {
() => ( {
...editorSettings,
__experimentalReusableBlocks: reusableBlocks,
__experimentalShouldInsertAtTheTop: isTitleSelected,
} ),
[ reusableBlocks ]
[ editorSettings, reusableBlocks, isTitleSelected ]
);
}

Expand Down