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

Fixed #8454 - Tooltip | Touch events support for Tooltip #14452

Closed
wants to merge 1 commit into from

Conversation

mehmetcetin01140
Copy link
Contributor

Fixes #8454

Copy link

vercel bot commented Dec 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated (UTC)
primeng ⬜️ Ignored (Inspect) Dec 29, 2023 11:16am

Copy link

Thanks a lot for your contribution! But, PR does not seem to fit our code format standards. Please run the 'npm run format' command and commit the changes.

@github-actions github-actions bot added the Resolution: Needs Revision The pull request can't be merged. Conflicts need to be corrected or documentation and code updated. label Dec 29, 2023
@@ -289,6 +300,10 @@ export class Tooltip implements AfterViewInit, OnDestroy {
return this.getOption('autoHide');
}

isMobile(): boolean {
return DomHandler.isIOS() || DomHandler.isAndroid();

Choose a reason for hiding this comment

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

shouldn't this only check if it is isTouchDevice?

@@ -304,6 +319,18 @@ export class Tooltip implements AfterViewInit, OnDestroy {
}
}

onTouchStart(e: TouchEvent) {

Choose a reason for hiding this comment

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

Suggested change
onTouchStart(e: TouchEvent) {
onTouchStart(e: TouchEvent): void {

let target = this.getTarget(this.el.nativeElement);
target.addEventListener('focus', this.focusListener);
target.addEventListener('blur', this.blurListener);
if (this.isMobile()) {

Choose a reason for hiding this comment

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

There are too many nested if, which makes this code hard to read. Can we split it into smaller sub-methods?

this.el.nativeElement.addEventListener('touchstart', this.touchStartListener);
this.el.nativeElement.addEventListener('touchend', this.touchEndListener);
} else {
if (this.getOption('tooltipEvent') === 'hover') {

Choose a reason for hiding this comment

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

I liked what you did with isMobile can you do same here? Like isHoverEvent or so?

this.el.nativeElement.addEventListener('mouseenter', this.mouseEnterListener);
this.el.nativeElement.addEventListener('click', this.clickListener);
this.el.nativeElement.addEventListener('mouseleave', this.mouseLeaveListener);
} else if (this.getOption('tooltipEvent') === 'focus') {

Choose a reason for hiding this comment

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

I liked what you did with isMobile can you do same here? Like isFocusEvent or so?

}
}

onTouchEnd(e: TouchEvent) {

Choose a reason for hiding this comment

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

Suggested change
onTouchEnd(e: TouchEvent) {
onTouchEnd(e: TouchEvent): void {

if (!this.container && !this.showTimeout) {
this.showTimeout = setTimeout(() => {
this.activate();
}, 500);

Choose a reason for hiding this comment

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

500 was chosen based on what? Can it be less?

@nkosi23
Copy link

nkosi23 commented Feb 11, 2024

@mehmetcetin01140 Are you still interested in finalizing this pull request? I was just considering contributing this feature since i need it but it seems that you are almost done already

@nkosi23
Copy link

nkosi23 commented Feb 17, 2024

@mehmetcetin01140 Poke?

@cetincakiroglu cetincakiroglu deleted the issue-8454 branch February 23, 2024 13:09
@nkosi23
Copy link

nkosi23 commented Mar 21, 2024

@cetincakiroglu Why was this closed, has a decision been made through another channel regarding a better approach to follow? Otherwise is it ok if I open a new PR to carry on this work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Needs Revision The pull request can't be merged. Conflicts need to be corrected or documentation and code updated.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Touch events support for Tooltip
4 participants