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

Tooltip: stop relying on Browser touch property #7535

Merged
merged 1 commit into from
Nov 1, 2021

Conversation

johnd0e
Copy link
Collaborator

@johnd0e johnd0e commented Mar 29, 2021

Rationale: #6978

@johnd0e
Copy link
Collaborator Author

johnd0e commented Mar 29, 2021

getEvents: function () {
var events = DivOverlay.prototype.getEvents.call(this);
if (Browser.touch && !this.options.permanent) {
events.preclick = this._close;
}
return events;
},

var onOff = remove ? 'off' : 'on',
events = {
remove: this.closeTooltip,
move: this._moveTooltip
};
if (!this._tooltip.options.permanent) {
events.mouseover = this._openTooltip;
events.mouseout = this.closeTooltip;
if (this._tooltip.options.sticky) {
events.mousemove = this._moveTooltip;
}
if (Browser.touch) {
events.click = this._openTooltip;
}
} else {
events.add = this._openTooltip;
}

In fact for modern browsers we could avoid handling clicks, and rely just on compatibility mouseover/mouseout even for touch.

@johnd0e
Copy link
Collaborator Author

johnd0e commented Mar 29, 2021

Going beyond subject: I'd prefer tooltips to behave in slightly different way: if opened on click - do not close on mouseout.

Reason: while such behavior is quite similar to current - it is more flexible, as it would also allow to keep tooltip opened, for convenience.

In this way we could use non-permanent tooltips with some interactive content (e.g. html link).

@Falke-Design
Copy link
Member

Do you think Browser.touch was used here because of performance or because of a other reason?

Currently in most places of code touch property check is used to prevent attaching excessive listeners if touch is unsupported.
May be that makes sense for legacy devices (though I doubt that it has any impact on performance with modern ones).

Originally posted by @johnd0e in #6978 (comment)

@johnd0e
Copy link
Collaborator Author

johnd0e commented Oct 31, 2021

Do you think Browser.touch was used here because of performance or because of a other reason?

I think that mentioned code was written with some assumptions in mind, which used to be true in that times.
But things are changing.

No, I do not think that it's about performance here.
It's rather about clear code logic - "if we use touch device than we need additional handling".
It's convenient logic but nowadays we are unable to say for true if touch device be used or not.

Copy link
Member

@Falke-Design Falke-Design left a comment

Choose a reason for hiding this comment

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

I didn't tested it but looks good

@Falke-Design
Copy link
Member

@mourner your part to approve and merge 😉

@mourner mourner merged commit e0af258 into Leaflet:master Nov 1, 2021
@johnd0e johnd0e deleted the tooltip-touch-retire branch November 1, 2021 08:29
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.

3 participants