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

fix(lib): start selection inbetween select items #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PhOder
Copy link

@PhOder PhOder commented Nov 28, 2022

This commit fixes the issue of not being able to start a selection if mousedown occured on neither Host element nor select item element but inbetween. The issue occurs if SelectItems are not direct children of the SelectContainer.

Fixes #144

@PhOder
Copy link
Author

PhOder commented Nov 29, 2022

Hi @d3lm thank you for this great library! :)

As this is my first PR in Github I'm sure there's going to be a couple of things I should fix. So please just let me know if you've got any feedback 👍

@d3lm
Copy link
Owner

d3lm commented Nov 29, 2022

Thanks! And also thanks for your PR, really appreciate it. I ll have a look at your PR 👍

@officiallyvenkatesan
Copy link

officiallyvenkatesan commented Jul 26, 2024

Hi @d3lm, why this PR not yet accepted. I checked this and it's working as expected. I need this change for my project. So give this feature ASAP.
Thank you!

@d3lm
Copy link
Owner

d3lm commented Jul 28, 2024

Hey there! If you really need this you always have the option to fork it. I am not maintaining this library in a full-time nor part-time capacity at the moment and I have many other responsibilities so I ask for a bit of understanding. I just didn't have the time to look at this PR yet. I am afraid that being pushy won't help much here.

Copy link
Owner

@d3lm d3lm left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Left some minor remarks.

@@ -91,6 +93,82 @@ describe('Dragging', () => {
.dispatch('mouseup');
});
});

describe('selection with dragOverItems set to false', () => {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
describe('selection with dragOverItems set to false', () => {
describe('Selection with dragOverItems set to false', () => {

Copy link
Author

Choose a reason for hiding this comment

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

done

});
});

it('should start selection in element inbetween SelectContainer and SelectItem', () => {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
it('should start selection in element inbetween SelectContainer and SelectItem', () => {
it('should start selection on element inbetween SelectContainer and SelectItem', () => {

Copy link
Author

Choose a reason for hiding this comment

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

done

});
});

describe('selection with selectOnClick set to false', () => {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
describe('selection with selectOnClick set to false', () => {
describe('Selection with selectOnClick set to false', () => {

Copy link
Author

Choose a reason for hiding this comment

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

done

});
});

it('should start selection in element inbetween SelectContainer and SelectItem', () => {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
it('should start selection in element inbetween SelectContainer and SelectItem', () => {
it('should start selection on element inbetween SelectContainer and SelectItem', () => {

Copy link
Author

Choose a reason for hiding this comment

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

done

cy.get('mat-grid-list')
.as('end')
.scrollIntoView()
.wait(16)
Copy link
Owner

Choose a reason for hiding this comment

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

Why are all these manual wait points necessary? Generally I'd say it's not ideal especially because Cypress has automatic wait points built-in in almost all APIs. Can you elaborate why these are needed?

Copy link
Author

Choose a reason for hiding this comment

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

Just removed the waits and it's working just fine... not sure if these were required back when I created the PR but I probably just copypasta'd from

without really looking/understanding the above comment. So I guess it's not necessary for my test scenario?

Plus I'm not familiar with Cypress, only been using Playwright so far 🙈

@@ -680,4 +683,13 @@ export class SelectContainerComponent implements AfterViewInit, OnDestroy, After

return null;
}

private _isClickOutsideSelectableItem(element: EventTarget): boolean {
if (!(element instanceof HTMLElement)) return false;
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if (!(element instanceof HTMLElement)) return false;
if (!(element instanceof HTMLElement)) {
return false;
}

Copy link
Author

Choose a reason for hiding this comment

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

done

private _isClickOutsideSelectableItem(element: EventTarget): boolean {
if (!(element instanceof HTMLElement)) return false;

if (element === this.host) return true;
Copy link
Owner

Choose a reason for hiding this comment

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

Add a block here too.

Copy link
Author

Choose a reason for hiding this comment

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

done

if (!(element instanceof HTMLElement)) return false;

if (element === this.host) return true;
if (this._selectableItemsNative.includes(element)) return false;
Copy link
Owner

Choose a reason for hiding this comment

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

Newline before and add a block.

Copy link
Author

Choose a reason for hiding this comment

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

done

@PhOder
Copy link
Author

PhOder commented Jul 29, 2024 via email

This commit fixes the issue of not being able to start a selection if
mousedown occured on neither Host element nor select item element
but inbetween. The issue occurs if `SelectItem`s are not direct children
of the `SelectContainer`.

Fixes d3lm#144
@PhOder PhOder force-pushed the fix/144-select-on-click-prevents-drag-box-between-items branch from 308a731 to 23c2665 Compare July 31, 2024 21:12
@PhOder
Copy link
Author

PhOder commented Jul 31, 2024

Thanks for the review @d3lm I hope everything checks out okay now :)

@officiallyvenkatesan
Copy link

officiallyvenkatesan commented Aug 4, 2024

Hello @d3lm
I hope this message finds you well. I am a dedicated user of this package. Firstly, I would like to express my sincere gratitude for your continuous efforts in maintaining and improving this invaluable resource. I am writing to bring to your attention a recent pull request submitted by @PhOder. This update is particularly important for my current project as it would provide enhanced user experience.
I fully understand and respect the careful consideration required for reviewing and merging pull requests to ensure the highest standards of quality and stability. Given the significant positive impact these changes could have on my project, I kindly request your consideration in reviewing and accepting this pull request.
Thank you very much for your attention and understanding. I look forward to your positive response.

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.

[selectOnClick]="false" option prevents initiating a drag box between items
3 participants