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

The userSelectAction change doesn't lead to selection state re-evaluation #493

Closed
oleksandr-danylchenko opened this issue Dec 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@oleksandr-danylchenko
Copy link
Contributor

oleksandr-danylchenko commented Dec 13, 2024

Issue behavior

The selection state evaluation is based on the currentUserSelectAction to assign whether an annotation is editable.

const selected = annotations.reduce<{ id: string, editable?: boolean }[]>((sel, a) => {
const action = onUserSelect(a, currentUserSelectAction, adapter);
if (action === UserSelectAction.EDIT)
return [...sel, { id: a.id, editable: true }];
else if (action === UserSelectAction.SELECT)
return [...sel, { id: a.id }];
else
return sel;
}, []);
set({ selected, event });

// If editable isn't set, use the default behavior
const isEditable = editable === undefined
? onUserSelect(annotation, currentUserSelectAction, adapter) === UserSelectAction.EDIT
: editable;

However, when a consumer changes the userSelectionAction, the selection state won't be updated respectively:

const setUserSelectAction = (action: UserSelectActionExpression<E> | undefined) =>
currentUserSelectAction = action;

That way, a user can create an "impossible" state where the userSelectAction is SELECT or NONE, but both the selected is present and the editable is true.

@oleksandr-danylchenko oleksandr-danylchenko added the bug Something isn't working label Dec 13, 2024
rsimon added a commit that referenced this issue Dec 19, 2024
…-selection-state

#493 Added selection state re-evaluation on `userSelectAction` change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant