-
Notifications
You must be signed in to change notification settings - Fork 304
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
Select profile if any of its choices are interacted with #729
Conversation
Thanks for submitting your first pull request! You are awesome! 🤗 |
Hmm, I was trying to see why pre-commit.ci couldn't auto-fix https://results.pre-commit.ci/run/github/46604988/1683023436.r2OoP9CCQH6uz9H7a_tv_g. Wonder what is the cause here. |
@yuvipanda pre-commit.ci and we as maintainers doesn't have rights to push commits to this branch and that is whats caused the failure in pre-commit.ci. @batpad can you do |
Wieee thank you @batpad for working this!! I saw that this solution doesn't handle all interactions, just when something is changed. Do you have ideas on how we can select the radio button through any kind of interaction - even if its not changing something? |
@batpad looking into this a bit, I think the issue is that we define nested tags, which doesn't seem to be something thats considered okay to do, see https://stackoverflow.com/a/20842000/2220152. I don't think we need the tag on |
@consideRatio thanks for looking at this! Ah, I see, so if you click on the option but dont actually "change" it in the Select, it doesn't select the Profile, when it probably should. This is because we're currently binding to the "change" event on the Do you think it's okay to trigger the selection of the profile just when the user clicks the Select box? i.e. don't wait for Select to open and click on an Option. (I'll submit a quick commit so we can see what this looks like) We can try this with binding to the |
@batpad ah yes! I think I also think pressing the dropdown labels should work, and that can be fixed by updating the |
…ption is not changed
@consideRatio I pushed a commit to change the profile selection to happen on the click event. So now, the profile should be selected when you click on the Select box, regardless if you change the option or not. Thanks for that catch. Interestingly, the behaviour for me is slightly different on Chrome and Firefox. On Firefox: Profile Radio gets selected AFTER clicking on the option. On Chrome: Profile Radio gets selected immediately when clicking on the Select. Let me know if it helps to attach a video of the behaviour - although I think this fulfills the purpose of just making sure the Profile radio gets selected whenever someone clicks on the profile or interacts with it. |
Ah, another really good catch :-) - lemme get to that. Yes, ideally this can be fixed with the |
@consideRatio hmm I pushed a commit to add the click handler to the Also reading the StackOverflow issue you linked. Right, so the fundamental problem here was that we were trying to make the click work just using the
This seems to me like it would be a bit cleaner - result in cleaner markup, and if we need to have some JS anyways to make this work, it seems cleaner to have a single click event on the container. Let me know if this makes sense and this should actually be pretty quick to do. |
This is fine as it is, if you want you can go for the So, I suggest we stay with what we have here. But! Autoformatting - run do |
So I tried this with a Since label inside label is invalid according to the spec, I can just make that change, and maybe this is okay to go? I think it might be better to stay away from larger restructuring of the HTML? |
Oops, this is the second time I've seen your comments a bit late :-) - but I think with the latest commit doing the autoformatting I think this is good to go.
If we do want to keep the |
Btw I don't think we need to fix the nested label tag issue, it seems to work after all - so if it comes to retaining the styling vs stop nesting labels - then I favor retaining the styling as it was. |
Haa, apologies for not catching the styling regression in Chrome - so strange that the styling is fairly different in Firefox and now it's driving me a bit mad trying to figure out what's happening exactly :-) And apologies that what should have been a simple fix has spiraled a bit, but thanks again for your feedback and watchful eye. I'm going to play around a bit with the styling mostly to satisfy my own curiosity on what's happening here, but I think you're right: it's better to revert to the nested labels, since that all seemed to work. I do prefer adding the explicit click handler rather than adding the
I have to say that there's a part of me that still really does not like the nested labels, and inconsistencies I'm seeing between chrome and firefox are worrying me a bit. But I think we can take that up separately and focus this PR on just fixing the issue it set out to fix, which is simply selecting the profile when the "Select" is interacted with. Will revert to nested labels with the click handler on the label and push in a bit. Thanks again @consideRatio ! |
Thanks a lot for engaging on this issue, @consideRatio! |
Reverted to using the @consideRatio turns out the styling was totally an Oops on my part: I accidentally removed the Have left it at |
Just to clarify - this was just my brain on too little coffee or so - I accidentally removed a class and then my brain got confused - have tested between FF and Chrome again and things look consistent / fine. Sorry about that, and thanks again for catching. |
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.
Wieee this looks exactly like before testing on chrome, and works exactly as expected to fix #696.
I opened #734 about avoiding nested <label>
tags as it seems you have a quick followup fix for that without introducing a styling change! Nice!
Thank you for your thorough work on this @batpad!! ❤️ 🎉 🌻
This builds on top of this PR: #724
Fixes #696
Does:
js-
prefixed classes to the Select boxes and the Label containers - this is not strictly necessary, but I find it good practice to separate out classes used by Javascript<script>
tag to the end of the template with simple jQuery to react to changes to the select tag and ensure that the parent Input Radio is selected. If there's a strong preference, can move to a separate file right away, or can do that if and when the JS gets more complex.Stylistic choices:
Let me know if this works / if there's anything else that would be good to do here.
cc @yuvipanda