Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit 0dbba66

Browse files
authored
fix: LSDV-5058: Outliner filter filtering empty labels (#1369)
1 parent e811425 commit 0dbba66

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

src/components/Filter/filter-util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ const empty = (items: any[], filterItem: FilterListInterface) => {
189189
return items.filter((obj) => {
190190
const item = getFilteredPath(filterItem.path, obj);
191191

192-
return item === '' || !item || item === null || item === undefined;
192+
return item === '' || !item || item === null || item === undefined || item === 'blank';
193193
});
194194
};
195195

tests/functional/specs/outliner/filter.cy.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ const config = `
1313
</View>
1414
`;
1515

16+
const configWithAllowEmpty = `
17+
<View>
18+
<Image name="img" value="$image"></Image>
19+
<RectangleLabels name="tag" toName="img" allowEmpty="true">
20+
<Label value="Planet"></Label>
21+
<Label value="Moonwalker" background="blue"></Label>
22+
<Label value="Moonwalker 1" background="red"></Label>
23+
<Label value="Moonwalker 2" background="pink"></Label>
24+
<Label value="Moonwalker 3" background="yellow"></Label>
25+
</RectangleLabels>
26+
</View>
27+
`;
28+
1629
const image = 'https://htx-misc.s3.amazonaws.com/opensource/label-studio/examples/images/nick-owuor-astro-nic-visuals-wDifg5xc9Z4-unsplash.jpg';
1730

1831
const task = {
@@ -187,4 +200,56 @@ describe('Filter outliner scenario', () => {
187200
cy.get('[data-testid="filter-input"]').type('Moonwalker 4');
188201
cy.contains('All regions hidden').should('be.visible');
189202
});
203+
204+
it('isEmpty should filter empty labels', () => {
205+
LabelStudio.init({
206+
config: configWithAllowEmpty,
207+
task,
208+
});
209+
210+
LabelStudio.setFeatureFlagsOnPageLoad({
211+
[FF_LSDV_3025]: true,
212+
});
213+
214+
Labels.select('blank');
215+
216+
ImageView.drawRect(20, 20, 100, 100);
217+
218+
cy.get('[data-cy="filter-button"]').click();
219+
cy.contains('Add Filter').click();
220+
cy.get('[data-testid="operation-dropdown"]').click();
221+
cy.contains('is empty').click();
222+
Sidebar.hasRegions(1);
223+
});
224+
225+
it('Should filter regions if user add new regions', () => {
226+
LabelStudio.init({
227+
config,
228+
task,
229+
});
230+
231+
LabelStudio.setFeatureFlagsOnPageLoad({
232+
[FF_LSDV_3025]: true,
233+
});
234+
235+
cy.get('[data-cy="filter-button"]').click();
236+
cy.contains('Add Filter').click();
237+
cy.get('[data-testid="operation-dropdown"]').click();
238+
cy.contains('contains').click();
239+
cy.get('[data-testid="filter-input"]').type('Moonwalker 2');
240+
241+
Sidebar.hasRegions(1);
242+
243+
Labels.select('Moonwalker 2');
244+
ImageView.drawRect(20, 20, 20, 20);
245+
246+
Sidebar.hasRegions(2);
247+
248+
Labels.select('Planet');
249+
ImageView.drawRect(270, 450, 20, 20);
250+
251+
Sidebar.hasRegions(2);
252+
cy.contains('There are 4 hidden regions').should('be.visible');
253+
254+
});
190255
});

0 commit comments

Comments
 (0)