-
-
Notifications
You must be signed in to change notification settings - Fork 142
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
Event stop returns incorrect store.stored value #136
Comments
Could you elaborate the steps? |
I'm trying to access all stored elements from the 'stop' event, but I always get incorrect values, I resolved this by accessing the elements with |
I still don't really see the problem you're having :/ The sandbox example you've send it works as expected. Every time you add something to the selection the previously selected elements are logged... I slightly modified your sandbox to what you've described. |
Hmm, maybe I misunderstood the event, I though store would return current selected elemens, not previous. Anyway as I said, I tried to get the current selected elements. I resolved this by accessing the elements directly via dom. |
The currently selected elements can be accessed with |
That might be what I was looking for. But I see some inconsistent beheviour across event listeners. :/ When I select items with drag, it returns correct selected elements in https://codesandbox.io/s/viselect-vanilla-forked-gu7q6?file=/src/main.ts |
Hi. Same here. It was a bit difficult to understand that Regarding Anyway, I found myself performing a cumbersome math to get the selected items: const previousSelection = this.model.userSelection(this.me());
const added = store.changed.added.map((added) => added.dataset.slot);
const selected = store.selected.map((selected) => selected.dataset.slot);
const removed = store.changed.removed.map(
(removed) => removed.dataset.slot
);
const selection = previousSelection
.concat(selected)
.concat(added)
.filter((slot) => !removed.includes(slot)); Feels bad. Nice to know there's this selector: However, I'd still expect the library to provide this already calculated 🤷 |
@libasoles Aren't you looking for the |
@lubomirblazekcz I took another look at your problem and there's a difference for what counts as a selection and the whole selection altogether. Each drag-, click- and range-selection is a single selection and elements for this are available in |
What is the problem?
store.stored.length
returns 0 when selecting one item, 1 when selecting two, etc. it's one value behindPlease provide the steps to reproduce and create a CodeSandbox.
I am using the vanilla https://codesandbox.io/s/viselectvanilla-kt332
Your environment:
The text was updated successfully, but these errors were encountered: