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

Topology header - fix Enter in search #1005

Merged
merged 3 commits into from Apr 12, 2017
Merged

Topology header - fix Enter in search #1005

merged 3 commits into from Apr 12, 2017

Conversation

himdel
Copy link
Contributor

@himdel himdel commented Apr 11, 2017

In #955, we merged the various toolbar-like things into a proper custom toolbar. But this introduced a regression - since the whole custom toolbar is a form, pressing enter in the search box would submit the form. (ref: #955 (comment))

So.. catching the submit event to trigger the same action as the same button.

..except for some reason, when pressing Enter in an input in this form, the browser creates a click event on the button immediately following that input - which is the clear button, so .. not ideal :).

Adding a hidden button that triggers the right action as a workaround, and updating the miqHideSearchClearButton code to be able to cope.


The long term goal for this is to have this as an angular component that talks with the right TopologyController via an observable, but turns out we can't have angular in custom toolbars quite yet - ManageIQ/ui-components#64.

Cc @AparnaKarve, @skateman

Aparna.. this should fix the issue, but not sure how much luck you'll have using this for https://bugzilla.redhat.com/show_bug.cgi?id=1401823 in fine (assuming that BZ is meant for fine), since before #955, most topologies used shared/_topology_header.html.haml, which is not a proper toolbar but is angular.

…n* buttons

to prevent clicks on toolbar buttons within a form from submitting that form
so that pressing enter in the search field doesn't submit the form
For some reason, pressing enter in an input triggers a *click* event on the immediately following button. (Maybe something to do with a form without any input type=submit?)

Thus, and given the restrictions on this particular template, working around the issue by providing an invisible button which does the same thing as form submit does.

(Could have been just a `%button.hidden` by itself, except all `%button` elements in toolbars have a miqToolbarOnClick as the click handler.)

The change in `miqHideSearchClearButton` is to find the right button even if it is not an immediate sibling.
@miq-bot
Copy link
Member

miq-bot commented Apr 11, 2017

Checked commits https://github.com/himdel/manageiq-ui-classic/compare/c9f4dca69bcee74b462201aae339e3ebbc766dac~...e6059ecd37a9cc154f66c0ef0927e853b4190e2a with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
0 files checked, 0 offenses detected
Everything looks good. 🍰

@AparnaKarve
Copy link
Contributor

AparnaKarve commented Apr 11, 2017

Aparna.. this should fix the issue, but not sure how much luck you'll have using this for https://bugzilla.redhat.com/show_bug.cgi?id=1401823 in fine (assuming that BZ is meant for fine), since before #955, most topologies used shared/_topology_header.html.haml, which is not a proper toolbar but is angular.

Yes, I'm completely aware that the fix that I end up making for the above BZ would be 100% non-backportable for Fine.
Anyway, thanks for the quick turnaround (fixing this in master, that is) :)
(haven't tested it yet, will do it sometime today)

EDIT: Looks like you have also addressed the BZ.
I think you should mark this fine/no since we know this cannot be cherry-picked.
I'll work on a separate fix for Fine.

%button.hidden{'data-function' => 'miqCallAngular',
'data-function-data' => {:name => 'searchNode',
:args => []}.to_json}

Copy link
Contributor

Choose a reason for hiding this comment

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

Works great... I do not see the annoying page Refresh like I did before and it also does the search when I hit enter.

Although what I'm not too happy about is that this seems like a "brute force" approach, and hence not the most logical fix.
But I'm sure you must have given a fair amount of thought to this, and this is probably as good as it can get.
I understand that this is kinda tricky to fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, I completely agree this is a bad approach, I just couldn't fine any better yet :(.

Ultimately this should never be doing the miqCallAngular magic, except right now, custom toolbars is the one place where we can't use angular.. but I'll try to keep this in mind (well, in the issue anyway :D) and convert this as soon as we can :).

@AparnaKarve
Copy link
Contributor

Tested in UI. LGTM.

@AparnaKarve
Copy link
Contributor

@himdel This is the equivalent PR for Fine: #1010

Incredibly straight-forward :)

@martinpovolny
Copy link

martinpovolny commented Apr 12, 2017

@himdel: can you, please, set the labels on this PR?

(trying to guess some)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants