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

Fixes #32153 - Hide tooltip on multiselect all buttons #8428

Merged
merged 1 commit into from Apr 9, 2021

Conversation

tbrisker
Copy link
Member

@tbrisker tbrisker commented Apr 5, 2021

The tooltips remain shown on click because the elemnt they are attached
to is a a tag, which remains in focus until the user clicks elsewhere
so there is no focusout event fired.
For the deselect all button, the click handler calls
multiSelect('refresh') which in turn removes the multiselect element
(with the tooltip event handlers) from the DOM[1], leaving the tooltip
always displayed.

[1] https://github.com/lou/multi-select/blob/0.9.12/js/jquery.multi-select.js#L335

@theforeman-bot
Copy link
Member

Issues: #32153

@theforeman-bot theforeman-bot added Needs testing Not yet reviewed Legacy JS PRs making changes in the legacy Javascript stack labels Apr 5, 2021
@ezr-ondrej ezr-ondrej self-assigned this Apr 7, 2021
@@ -75,13 +75,15 @@ function sanitize(value){
$(document).on('click', '.ms-select-all', function () {
// can't use multiSelect('select_all') because it adds filtered out items too.
$(this).closest('.form-group').find('.ms-selectable .ms-list :visible').click();
$(this).tooltip('hide');
Copy link
Member

Choose a reason for hiding this comment

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

Now after clicking and another refocusing, it stays open.
Should we destroy as well? I think the tooltips get created on the fly now, so it will get recreated right?

Copy link
Member Author

Choose a reason for hiding this comment

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

hmmm, on additional testing looks like not all cases are properly handled:\ i'll work on it a bit further

Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out you can't destroy delegated tooltips - https://getbootstrap.com/docs/3.4/javascript/#tooltip-destroy. updated to hide on removal as well.

The tooltips remain shown on click because the elemnt they are attached
to is a `a` tag, which remains in focus until the user clicks elsewhere
so there is no `focusout` event fired.
For the deselect all button, the click handler calls
`multiSelect('refresh')` which in turn removes the multiselect element
(with the tooltip event handlers) from the DOM[1], leaving the tooltip
always displayed.
Since we only use tooltips for hover help, the `focus` trigger has been
removed. Popovers should be used when showing information that is
displayed on focus (i.e. when clicking on an element).

[1] https://github.com/lou/multi-select/blob/0.9.12/js/jquery.multi-select.js#L335
@@ -63,6 +63,7 @@ export function activateTooltips(elParam = 'body') {
el.tooltip({
selector: '[rel="twipsy"],*[title]:not(*[rel],.fa,.pficon)',
container: 'body',
trigger: 'hover',
Copy link
Member Author

Choose a reason for hiding this comment

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

The default for this is 'hover focus', however we don't actually use tooltips for places that require focus (we have popover for that).

@ezr-ondrej
Copy link
Member

[test foreman][test katello]

Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Works well 👍
Thanks @tbrisker !

@ezr-ondrej ezr-ondrej merged commit d3ddfac into theforeman:develop Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Legacy JS PRs making changes in the legacy Javascript stack Needs testing UI
Projects
None yet
3 participants