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
Allow an empty defaultValue
option for enhanceSelectElement
#128
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.
Good find! Are you happy to add a functional test (this one is a good reference) and a CHANGELOG line so I can merge and ship this straight away?
Very happy. Tests were on their way, but hit a slight blocker in that I was struggling to get them to run locally, and I was planning a separate PR to resolve my test issues. I'll get on the case though. |
4957ffb
to
3a9aad7
Compare
Turns out most of my test blockers were my own out-of-date installs (my local firefox was 23 major versions behind current!).
Got there in the end! |
The check for a default value option matches false-y values, but that also catches the case where the default value is explicitly set to an empty string. Add an extra condition for the case where the default value is '' so that it is not overwritten with the content of the first `<option>`.
3a9aad7
to
a864d57
Compare
@lennym well done! CI didn't succeed for one reason or another, I've ordered a rebuild. Will merge after. |
I saw. Thanks 💯 for your super fast help on this. |
@lennym sorry about this, CI seems to be having trouble connecting to Sauce Labs for the integration tests. It will take a bit longer to merge this while I investigate. I suspect it may be related to the fact that this PR is coming from an external fork, in which case I'd really like to fix this issue. |
No problem. I know there are issues in travis with secure environment variables not being available for PR builds to avoid them being vulnerable to malicious PRs. There's no urgency on our side at all. I just took on the spike to implement this as a "Friday afternoon job" - we're not necessarily planning on putting into production any time soon. |
That's the issue. I had Do you know of a good solution other than not providing this functionality and instead pulling remote code + opening separate PR + closing the one submitted by contributor? |
My only thought is possibly to build PRs with tests run "locally" against a phantomjs instance, and reserve a full saucelabs test for master builds. If it's any use, I made a little script helper for running conditional travis builds a while ago, which we found to help with doing things like this - https://www.npmjs.com/package/travis-conditions. We actually use it to get around this exact issue - namely we have auth tokens for snyk, which are unavailable for PRs. Edit: found the project in question: https://github.com/UKHomeOfficeForms/hof-bootstrap/blob/master/.travis.yml |
@lennym I thought about that, however, I had to move away from I'll open an issue to discuss this further but until then I will deactivate I'll merge this, and publish a new version after master builds. Thanks again! |
I'd strongly recommend trying a conditional build so you can still run your linter and unit tests on PRs. At least that way you can automate most of the testing. |
I've been doing a bit more looking at this this morning and I'm now unsure that what I've done is correct. Our desired behaviour (and IMO, what should probably be default behaviour) is something like this:
The problem with this is that it's quite tricky to "nicely" configure with the options as they are - you end up needing to add a condition to check if the I think a better approach is to incorporate this into the tl;dr - more PRs coming Edit: by "nicely" configure, I mean that the options to do this look like this: ac.enhanceSelectElement({
defaultValue: elm.value ? elm.options[elm.options.selectedIndex].innerHTML : '',
selectElement: elm
}); |
@lennym yes, that does sound like a more sensible default. 👌 |
Super. I'm just finishing off #130 and then I'll implement roughly what I've described above. |
The check for a default value option matches false-y values, but that also catches the case where the default value is explicitly set to an empty string.
Add an extra condition for the case where the default value is
''
so that it is not overwritten with the content of the first<option>
.