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

Fixing up logic around selecting/deselecting nested labels #13

Merged
merged 6 commits into from
Jul 27, 2024

Conversation

lizfaubell
Copy link

Summary:

There’s a bug in label studio where if you use labels for conditional labeling (creating nested labels), and don’t deselect the label you’re on before attempting to label something else, the console will throw a bunch of errors and beachball of death, forcing you to reload the page. Fixing this by not allowing users to select a different top-level label if there are sub-labels already applied. Also not allowing users to remove a top-level label if there are sub-labels since that logically doesn't make sense.

Issue: https://khanacademy.atlassian.net/browse/DI-1502

Test plan:

There’s a bug in label studio where if you use labels for conditional labeling (creating nested labels), and don’t deselect the label you’re on before attempting to label something else, the console will throw a bunch of errors and beachball of death, forcing you to reload the page. Fixing this  by not allowing users to select a different top-level label if there are sub-labels already applied. Also not allowing users to remove a top-level label if there are sub-labels since that logically doesn't make sense.

Issue: https://khanacademy.atlassian.net/browse/DI-1502

Test plan:
- deployed to test; see in action here: https://data-labeling-test.khanacademy.org/projects/298/data?tab=537&page=1
@lizfaubell lizfaubell self-assigned this Jul 26, 2024
<full summary>

Issue: <url or "none">

Test plan:
<see below>
<full summary>

Issue: <url or "none">

Test plan:
<see below>
<full summary>

Issue: <url or "none">

Test plan:
<see below>
@lizfaubell lizfaubell requested review from dat-boris and a team July 27, 2024 00:02
@lizfaubell lizfaubell marked this pull request as ready for review July 27, 2024 00:02
if (
labels.selectedLabels.length === 1 &&
self.selected &&
labels.selectedLabels[0].value == self.value &&

Choose a reason for hiding this comment

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

🚫 [eslint] <eqeqeq> reported by reviewdog 🐶
Expected '===' and instead saw '=='.

src/tags/control/Label.js Outdated Show resolved Hide resolved
!labels.selectedLabels[0].alias && // Hack: we only gave sub-labels aliases
region.labelings.length > 1
) {
console.log("can't deselect top level label w sub label!")

Choose a reason for hiding this comment

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

🚫 [eslint] <semi> reported by reviewdog 🐶
Missing semicolon.

Suggested change
console.log("can't deselect top level label w sub label!")
console.log("can't deselect top level label w sub label!");

Copy link
Collaborator

@dat-boris dat-boris left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for working this one out!

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
!labels.selectedLabels[0].alias && // Hack: we only gave sub-labels aliases
region.labelings.length > 1
) {
console.log('can\'t deselect top level label w sub label!')

Choose a reason for hiding this comment

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

🚫 [eslint] <semi> reported by reviewdog 🐶
Missing semicolon.

Suggested change
console.log('can\'t deselect top level label w sub label!')
console.log('can\'t deselect top level label w sub label!');

<full summary>

Issue: <url or "none">

Test plan:
<see below>
@lizfaubell lizfaubell merged commit e633083 into master Jul 27, 2024
4 of 5 checks passed
khan-actions-bot pushed a commit to Khan/label-studio that referenced this pull request Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants