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

Refactoring init.js of Designer #15338

Merged
merged 1 commit into from Jun 18, 2019

Conversation

@Bournvita1998
Copy link
Contributor

@Bournvita1998 Bournvita1998 commented Jun 17, 2019

Signed-off-by: Bournvita1998 mohit.kuri@research.iiit.ac.in

Description

Refactoring in the init.js of the designer section

Fixes #

Before submitting pull request, please review the following checklist:

  • Make sure you have read our CONTRIBUTING.md document.
  • Make sure you are making a pull request against the correct branch. For example, for bug fixes in a released version use the corresponding QA branch and for new features use the master branch. If you have a doubt, you can ask as a comment in the bug report or on the mailing list.
  • Every commit has proper Signed-off-by line as described in our DCO. This ensures that the work you're submitting is your own creation.
  • Every commit has a descriptive commit message.
  • Every commit is needed on its own, if you have just minor fixes to previous commits, you can squash them.
  • Any new functionality is covered by tests.
Signed-off-by: Bournvita1998 <mohit.kuri@research.iiit.ac.in>
shucon
shucon approved these changes Jun 17, 2019
@ibennetch ibennetch merged commit 0509497 into phpmyadmin:gsoc-db-designer Jun 18, 2019
2 of 3 checks passed
@ibennetch
Copy link
Member

@ibennetch ibennetch commented Jun 18, 2019

Good job.

@@ -54,22 +54,22 @@ AJAX.registerOnload('designer/init.js', function () {
}

$('#query_Aggregate_Button').on('click', function () {
document.getElementById('query_Aggregate').style.display = 'none';
$('#query_Aggregate').style.display = 'none';
Copy link
Member

@devenbansod devenbansod Jun 18, 2019

@Bournvita1998 shouldn't we be using $("#id").css("display", "none"); or $("#id").hide(); here?

Copy link
Contributor Author

@Bournvita1998 Bournvita1998 Jun 28, 2019

@devenbansod I didn't find a good article comparing the difference between these 3. I know they all does the same job but no idea what's the difference. Can you help me knowing the difference between them?

Copy link
Contributor Author

@Bournvita1998 Bournvita1998 Jul 1, 2019

@devenbansod, for now, I am thinking of moving ahead making the changes in a similar way as I have done here. If required, we will change them again.

Copy link
Member

@devenbansod devenbansod Jul 1, 2019

@Bournvita1998 have you tested this in the browser?

AFAIK, $('selector') returns an array-like JQuery-native object and doesn't return a native DOM element. So if I'm not mistaken, this code change would throw an error: Uncaught TypeError: Cannot set property 'display' of undefined in the console.

Ref for the css API: https://api.jquery.com/css/

Copy link
Contributor Author

@Bournvita1998 Bournvita1998 Jul 4, 2019

@devenbansod Yeah you are right here. $('selector') will return an array of all possible matches but document.getElementById('ID') returns just the first match it finds. To resolve this error we can either do the things as you suggested in your first comment or we can change $('selector') to $('selector')[0]. I found this on stackoverflow explaining the difference between jQuery object and DOM elements.

Also, I found the same issue in my previously created PRs too, which need to be changed soon. I am thinking of replacing them using the css format like: $("#id").css("display", "none"); is that fine to move ahead?

Copy link
Member

@devenbansod devenbansod Jul 7, 2019

Sure, please go ahead 👍

Copy link
Member

@williamdes williamdes Jun 11, 2021

This was indeed invalid: #16960

@williamdes
Copy link
Member

@williamdes williamdes commented Jun 11, 2021

Gosh, why did I approve this invalid code.. 🤦🏻
Ref: #16960

williamdes added a commit that referenced this issue Jun 11, 2021
Error created by pull-request #15338 in fec7de8

Signed-off-by: William Desportes <williamdes@wdes.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants