-
Notifications
You must be signed in to change notification settings - Fork 152
add hide_by_default attribute option #4620
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
base: master
Are you sure you want to change the base?
Conversation
It should also be noted when this is added to the docs that this is only supported on select trigger elements, since data-show-when-checked would be equivalent to data-hide-when-unchecked, and we should prefer data-hide |
// safe to access directly? | ||
const hide = hideLookup[id].get(changeId, val); | ||
if((hide === false) || (hide === undefined && !initializing)) { | ||
if((hide === false) || (hide === undefined && !initializing && !hideByDefault)) { |
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.
Looking at this expression after all this time - does data-hide-something: false
just work here?
Without pulling this down, just reading through it, I wonder if it solves the original issue. The OP mentions adding a |
That certainly would be a direction we could take this, I guess it depends how much value we see in making a server-side form processing component. Robin mentions that automatic detection would be preferable, but if we want to stop this from launching other significant changes, the |
This reverts commit 6750990.
Thank you for this. I just pulled this down and tested it a bit. Functionality wise, this seems to do what it needs to do in our use case. |
The hide_by_default approach should be implemented now, it took a lot of little tweaks to get the wrapper div hidden properly, probably a sign that we would want to refactor this to get a single |
We shouldn't apply inline styles. Can we just add the |
It has to do with the way data-hide actually hides the elements, which is by going in and adding the inline |
That makes sense, no need to investigate I think we likely have to follow jQuery to be compatible with everything else. |
Yeah I just tested real quick and Still writing tests as well so those should be coming soon |
I'm not in love with wrappers in this and IIRC another PR. Can we just embed a |
Testing finished with coverage over all the form widgets, so should be ready to merge after a final review. I will say I am a little concerned about the size of |
I think the issue is that the widgets are very flexible as far as how much we rely on bootstrap-form vs our own code. Ideally we don't have to manually handle the wrapper key nearly this much, but for the ones that we don't define the The easiest fix IMO would be to add a single universal wrapper on top of every widget with class This would require changing the operation of data-hide though, and may work better as a future refactor |
The issue is getting the attribute into the right location in the html, since the element we need to hide isn't always defined by us. The |
I feel like this is on hold due to the need to refactor. Is that right? If so, I'd say let's just close it because it'll be open for some time then likely needs a major conflict resolution. |
It is very well tested against all the widgets, and there is only one conflict so far and it shouldn't be too bad I don't think (all of the unwanted complexity is server-side not javascript, which we have had to mess with much less). It definitely is something that will be cleaner once we get to that refactor, but if it works and is well tested, I think we should get it out so people can start using it, and then clean up the implementation later. We could still push it back if we run into any major issues though. |
What's worrisome to me is the updates in I agree with the sentiment that this could be a nice addition, but I just get the sense that it'll be hard to extract and revert. At least cleanly. Now I am in-fact wondering if we should to do the refactor now or at least consider it. I wonder how long it'd take? It seems like we just need to wrap every element which seems easy enough. New features like this can utilize it and older features can continue to do what they do. Can you take a couple hours to hack and see if it's easy & simple to just do now while maintaining compatibility with the existing features? |
I think doing the full refactoring, which to do right should involve looking into all 19 extant issues in #2476 and how we can make those things easier at all levels, is best reserved as a task of its own. I can definitely look into ways we can make this closer to what we think the refactoring will be. My first impression is that I do think we could wrap each widget with hide-specific divs (maybe incorporate the widget info divs from #4594), and that would clean up the session_contexts_helper quite a bit. However this comes at the expense of HTML simplicity (slightly) and will require a more complex implementation for hiding elements than the built in jquery method. The only other downside I see is that we may need to get rid of bootstrap-form for accessibility soon, and since working around the inconsistencies of bootstrap-form and the custom widgets is the real pain point of these changes, we may end up building our own widget helper functionality out to do what we want bootstrap-form to do (reading a hash of wrapper attributes and applying this consistently). This would allow us to handle every widget both even-handedly and cleanly. If we went that direction every widget would look like the select widget does in these changes, and it would all be pretty straightforward. Anyway just my first impressions of the problem, I will take a closer look and see how the wrapper approach looks. Assuming no major complications, I'll add those changes to this PR after I resolve the current test conflicts. |
I'd really prefer a separate PR. It's very hard to evaluate changes when multiple things are happening. |
Fixes #3346 by passing a boolean
hideByDefault
parameter toaddHideHandler
andupdateVisibility
. Due to the caching, this will only allow one of either data-hide or data-show actions to apply to an trigger element, automatically avoiding conflicts by using the first one passed.There is a slight issue where if the data-show directive is not on the initial setting for the trigger element, the hidden element flashes briefly on the form before it is hidden. The only way to fix this is to have it be hidden by default on html render, which would require parsing the implications of
form.yml
server-side. I don't think this is a bad idea, and could be a good way to check form viability and warn if any dynamic form conventions are not being followed (eg. data-hide and data-show in same trigger element, data-label not set on all options, etc) but will be a much greater change that should likely be a PR of its own.Testing for data-show will be added shortly, but wanted to get this up to discuss the previous point.