Skip to content

Rebase commits onto upstream #859 #4

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

Merged
merged 2 commits into from
Apr 24, 2024
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
6 changes: 4 additions & 2 deletions docs/api-reference/layers/selection-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ Either `rectangle` or `polygon`

Called when selection is completed.

#### `layerIds` (String[], required)
#### `layerIds` (String[], optional)

Array of layer ids where we will search.
- Default: `null`

Array of layer ids where we will search. If not specified, then all pickable and visible layers are searched.
2 changes: 1 addition & 1 deletion modules/editor/test/importer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('parseImport()', () => {
expect(importData.valid).toEqual(false);
expect(importData.validationErrors).toEqual([
'Error parsing GeoJSON',
'SyntaxError: Unexpected token a in JSON at position 1',
"SyntaxError: Expected property name or '}' in JSON at position 1",
]);
});
});
Expand Down
16 changes: 13 additions & 3 deletions modules/layers/src/layers/selection-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ const MODE_CONFIG_MAP = {
};

interface SelectionLayerProps<DataT> extends CompositeLayerProps<DataT> {
layerIds: any[];
layerIds: any[] | null;
onSelect: (info: any) => any;
selectionType: string | null;
}

const defaultProps: DefaultProps<SelectionLayerProps<any>> = {
selectionType: SELECTION_TYPE.RECTANGLE,
layerIds: [],
layerIds: null,
onSelect: () => {},
};

Expand Down Expand Up @@ -124,12 +124,22 @@ export default class SelectionLayer<DataT, ExtraPropsT> extends CompositeLayer<

// HACK, find a better way
setTimeout(() => {
let selectionLayerIds = layerIds;
if (!selectionLayerIds) {
// Provide all visible and pickable layers to pickObjects when layerIds is not provided.
selectionLayerIds = this.context.layerManager
.getLayers()
.filter((layer) => layer.props.pickable && layer.props.visible)
.map((layer) => layer.props.id);
}

// @ts-ignore
const pickingInfos = this.context.deck.pickObjects({
x,
y,
width: maxX - x,
height: maxY - y,
layerIds: [blockerId, ...layerIds],
layerIds: [blockerId, ...selectionLayerIds],
});

onSelect({
Expand Down