-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
max-height/offsetHeight Calculation Issue, Fixes #2581 #2653
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
- use single quotes, see: https://app.codacy.com/gh/snapappointments/bootstrap-select/pullRequest?prid=8039996
- don't use variable name with a
$
. I know it's like that in some part of the code (not many), but I think it's weird and doesn't convey meaning (other than it's a jquery object) - please use long and meaningful variable names
- itemIsBlank shouldn't exist, just compare directly
- you should define
$a
first (renamed as per 3.) and callshow()
on it instead of defining it after and repeating the selector.
Note that I haven't run your code yet, this is a quick review on the diff I see.
Hello Terry, thank you for your contribution, I made a quick review, please address my comments. |
|
js/bootstrap-select.js
Outdated
if (itemIsBlank) { | ||
var newElementAnchor = $('a', $(li)); | ||
newElementAnchor.show(); // always make sure first item is shown, otherwise offsetHeight = 0 | ||
if (newElementAnchor.text() == '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ===
here. I will add a proper eslint config at some point for this kind of stuff.
…) and after offsetHeight was calculated
Added === check and added some addition code to preserve/restore css. Let me know if anything else is needed. |
@terryaney thanks, please make the linter happy (you can run it locally, too!) |
I've updated. If linter still failing, could you tell me how I run locally? FYI, I'm editing the file in VS Code, but I'm not opening the folder or anything (just the single file). I'll google in the meantime. |
You can run it locally with |
Doesn’t seem to be working.
Sent from Mail for Windows
From: Nicolas CARPi
Sent: Friday, January 14, 2022 3:25 PM
To: snapappointments/bootstrap-select
Cc: Terry Aney; Mention
Subject: Re: [snapappointments/bootstrap-select] max-height/offsetHeight Calculation Issue, Fixes #2581 (#2653)
You can run it locally with npm run lint.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
No it's working but you need to get a proper dev env with |
I guess I'm still confused because I expect there to be a "lint" script/action present inside package.json but it isn't there and I obviously don't want to edit that file. Disclaimer, I do 99% of my dev in Visual Studio on server side code so my npm/VS Code skills are still very green. I ran
|
@terryaney Sorry it's my bad, I mixed up projects in my head. This project uses |
OK, so to run it, it was simply Secondly, after running that (or maybe the |
See #2681 for the dist issue (no longer an issue). You don't have the |
Going to start over after pulling latest code. |
Fixes #2581
If the number of items in the dropdown >
this.options.size
, then the following line runs:menuHeight = liHeight * this.options.size + divLength * divHeight + menuPadding.vert;
However,
liHeight
is calculated wrong if the first item is hidden or if first item has text of''
.Before adding the temporary
newElement
to thebody
to calculate height, I always show the first item (I didn't check to see if hidden), and if first items text =''
, I set it to
(probably wouldn't need a check here either).