Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a64ecd8
Release script: Update react-native-editor version to 1.81.0
derekblank Aug 4, 2022
29d06a6
Release script: Update with changes from 'npm run core preios'
derekblank Aug 4, 2022
4d1ca7e
Release script: Update react-native-editor version to 1.81.1
dcalhoun Aug 24, 2022
78fc8f4
Release script: Update with changes from 'npm run core preios'
dcalhoun Aug 24, 2022
9edbebe
[Mobile] - Add BlockListCompact (#43431)
Aug 25, 2022
201e83a
[RNMobile] List block v2: Fix text color inconsistencies with list it…
derekblank Aug 19, 2022
f41577e
Mobile - Disable FastImage on Android (#43322)
Aug 18, 2022
a439a53
[Mobile] - Fix dynamic React Native version (#43058)
Aug 8, 2022
94b8447
[RNMobile] Use default placeholder text color for native List Item (#…
derekblank Aug 25, 2022
8599e8c
Mobile - Update CHANGELOG
Aug 25, 2022
10fef38
Release script: Update react-native-editor version to 1.82.0
SiobhyB Sep 1, 2022
4e2512c
Release script: Update with changes from 'npm run core preios'
SiobhyB Sep 1, 2022
60199dc
[RNMobile] Set tintColor for ActionSheetIOS (#42996)
SiobhyB Aug 8, 2022
7fe980b
Update picker's .scss to follow BEM convention (#43036)
SiobhyB Aug 22, 2022
5157b3d
Update CHANGELOG with 1.82.0 changes
SiobhyB Sep 1, 2022
570fd2d
Release script: Update react-native-editor version to 1.82.1
SiobhyB Sep 6, 2022
059e5c1
Release script: Update with changes from 'npm run core preios'
SiobhyB Sep 6, 2022
59dd5de
Mobile - List V2 - Prevent error when list is empty (#43861)
Sep 5, 2022
f761037
[Mobile] List V2 - Fixes split issues (#43949)
Sep 7, 2022
0ef2c30
Update CHANGELOG to include 1.82.1 changes
SiobhyB Sep 8, 2022
b32d772
Merge branch into trunk
SiobhyB Sep 8, 2022
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
Prev Previous commit
Next Next commit
[Mobile] - Add BlockListCompact (#43431)
* Mobile - Introduce BlockListCompact - Lighter version of the default BlockList with simpler functionality for use cases like the List V2 block

* Mobile - Update List V2 tests since it's not needed to fire the layout event change with the BlockListCompact component

* Mobile - BlockListCompact - Add note of the component props and which block is currently using it
  • Loading branch information
Gerardo Pacheco authored Aug 25, 2022
commit 9edbebed1a1078de98271f05c2f45ef35bbca8ea
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* External dependencies
*/
import { View } from 'react-native';

/**
* WordPress dependencies
*/
import { store as blockEditorStore } from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';

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

/**
* NOTE: This is a component currently used by the List block (V2)
* It only passes the needed props for this block, if other blocks will use it
* make sure you pass other props that might be required coming from:
* components/inner-blocks/index.native.js
*/

function BlockListCompact( props ) {
const {
marginHorizontal = styles.defaultBlock.marginLeft,
marginVertical = styles.defaultBlock.marginTop,
rootClientId,
} = props;
const { blockClientIds } = useSelect(
( select ) => {
const { getBlockOrder } = select( blockEditorStore );
const blockOrder = getBlockOrder( rootClientId );

return {
blockClientIds: blockOrder,
};
},
[ rootClientId ]
);

const containerStyle = {
marginVertical: -marginVertical,
marginHorizontal: -marginHorizontal,
};

return (
<View style={ containerStyle }>
{ blockClientIds.map( ( currentClientId ) => (
<BlockListBlock
clientId={ currentClientId }
key={ currentClientId }
marginHorizontal={ marginHorizontal }
marginVertical={ marginVertical }
/>
) ) }
</View>
);
}

export default BlockListCompact;
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import getBlockContext from './get-block-context';
* Internal dependencies
*/
import BlockList from '../block-list';
import BlockListCompact from '../block-list/block-list-compact';
import { useBlockEditContext } from '../block-edit/context';
import useBlockSync from '../provider/use-block-sync';
import { BlockContextProvider } from '../block-context';
Expand Down Expand Up @@ -96,6 +97,7 @@ function UncontrolledInnerBlocks( props ) {
blockWidth,
__experimentalLayout: layout = defaultLayout,
gridProperties,
useCompactList,
} = props;

const block = useSelect(
Expand All @@ -112,8 +114,10 @@ function UncontrolledInnerBlocks( props ) {
templateInsertUpdatesSelection
);

const BlockListComponent = useCompactList ? BlockListCompact : BlockList;

let blockList = (
<BlockList
<BlockListComponent
marginVertical={ marginVertical }
marginHorizontal={ marginHorizontal }
rootClientId={ clientId }
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/list-item/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function ListItemEdit( {
} );
const innerBlocksProps = useInnerBlocksProps( blockProps, {
allowedBlocks: [ 'core/list' ],
renderAppender: false,
useCompactList: true,
} );

const onSplit = useSplit( clientId );
Expand Down
154 changes: 0 additions & 154 deletions packages/block-library/src/list/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,6 @@ describe( 'List V2 block', () => {

// Select List block
const listBlock = getByA11yLabel( /List Block\. Row 1/ );

fireEvent(
within( listBlock ).getByTestId( 'block-list-wrapper' ),
'layout',
{
nativeEvent: {
layout: {
width: 100,
height: 50,
},
},
}
);

fireEvent.press( listBlock );

// Select List Item block
Expand Down Expand Up @@ -180,61 +166,18 @@ describe( 'List V2 block', () => {
// Select List block
const listBlock = getByA11yLabel( /List Block\. Row 1/ );

fireEvent(
within( listBlock ).getByTestId( 'block-list-wrapper' ),
'layout',
{
nativeEvent: {
layout: {
width: 100,
height: 50,
},
},
}
);

fireEvent.press( listBlock );

// Select List Item block
const firstNestedLevelBlock = within( listBlock ).getByA11yLabel(
/List item Block\. Row 2/
);

fireEvent(
within( firstNestedLevelBlock ).getByTestId( 'block-list-wrapper' ),
'layout',
{
nativeEvent: {
layout: {
width: 100,
height: 350,
},
},
}
);

fireEvent.press( firstNestedLevelBlock );

// Select second level list
const secondNestedLevelBlock = within(
firstNestedLevelBlock
).getByA11yLabel( /List Block\. Row 1/ );

fireEvent(
within( secondNestedLevelBlock ).getByTestId(
'block-list-wrapper'
),
'layout',
{
nativeEvent: {
layout: {
width: 100,
height: 50,
},
},
}
);

fireEvent.press( secondNestedLevelBlock );

expect( getEditorHtml() ).toMatchSnapshot();
Expand All @@ -256,20 +199,6 @@ describe( 'List V2 block', () => {

// Select List block
const listBlock = getByA11yLabel( /List Block\. Row 1/ );

fireEvent(
within( listBlock ).getByTestId( 'block-list-wrapper' ),
'layout',
{
nativeEvent: {
layout: {
width: 100,
height: 50,
},
},
}
);

fireEvent.press( listBlock );

// Select Secont List Item block
Expand Down Expand Up @@ -300,60 +229,19 @@ describe( 'List V2 block', () => {

// Select List block
const listBlock = getByA11yLabel( /List Block\. Row 1/ );

fireEvent(
within( listBlock ).getByTestId( 'block-list-wrapper' ),
'layout',
{
nativeEvent: {
layout: {
width: 100,
height: 50,
},
},
}
);

fireEvent.press( listBlock );

// Select List Item block
const firstNestedLevelBlock = within( listBlock ).getByA11yLabel(
/List item Block\. Row 1/
);

fireEvent(
within( firstNestedLevelBlock ).getByTestId( 'block-list-wrapper' ),
'layout',
{
nativeEvent: {
layout: {
width: 100,
height: 350,
},
},
}
);

fireEvent.press( firstNestedLevelBlock );

// Select Inner block List
const innerBlockList = within( firstNestedLevelBlock ).getByA11yLabel(
/List Block\. Row 1/
);

fireEvent(
within( innerBlockList ).getByTestId( 'block-list-wrapper' ),
'layout',
{
nativeEvent: {
layout: {
width: 100,
height: 50,
},
},
}
);

// Select nested List Item block
const listItemBlock = within( innerBlockList ).getByA11yLabel(
/List item Block\. Row 1/
Expand Down Expand Up @@ -386,20 +274,6 @@ describe( 'List V2 block', () => {

// Select List block
const listBlock = getByA11yLabel( /List Block\. Row 1/ );

fireEvent(
within( listBlock ).getByTestId( 'block-list-wrapper' ),
'layout',
{
nativeEvent: {
layout: {
width: 100,
height: 50,
},
},
}
);

fireEvent.press( listBlock );

// Update to ordered list
Expand Down Expand Up @@ -428,20 +302,6 @@ describe( 'List V2 block', () => {

// Select List block
const listBlock = getByA11yLabel( /List Block\. Row 1/ );

fireEvent(
within( listBlock ).getByTestId( 'block-list-wrapper' ),
'layout',
{
nativeEvent: {
layout: {
width: 100,
height: 50,
},
},
}
);

fireEvent.press( listBlock );

// Update to ordered list
Expand Down Expand Up @@ -481,20 +341,6 @@ describe( 'List V2 block', () => {

// Select List block
const listBlock = getByA11yLabel( /List Block\. Row 1/ );

fireEvent(
within( listBlock ).getByTestId( 'block-list-wrapper' ),
'layout',
{
nativeEvent: {
layout: {
width: 100,
height: 50,
},
},
}
);

fireEvent.press( listBlock );

// Update to ordered list
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/list/v2/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function Edit( { attributes, setAttributes, clientId, style } ) {
...( Platform.isNative && {
marginVertical: NATIVE_MARGIN_SPACING,
marginHorizontal: NATIVE_MARGIN_SPACING,
useCompactList: true,
} ),
} );
useMigrateOnLoad( attributes, clientId );
Expand Down