lemonsaurus / django-simple-bulma

Django application to add the Bulma CSS framework and its extensions
MIT License
136 stars 16 forks source link

Add script to handle dropdown menus #59

Closed JonasUJ closed 4 years ago

JonasUJ commented 4 years ago

Closes #27, which is one of the issues we needed to solve in #57.

JonasUJ commented 4 years ago

I hope you don't mind me merging into submodule_refactor instead of version-2-0-0. This depends on stuff in there.

lemonsaurus commented 4 years ago

@JonasUJ I've already merged the submodule_refactor branch into master, so there is no need to target it with this PR.

JonasUJ commented 4 years ago

Oh, then what is the version-2-0-0 branch for?

MarkKoz commented 4 years ago

It was the branch used by #58

lemonsaurus commented 4 years ago

It was the branch used by #58

I've gone through and removed some of the merged branches now, to prevent further confusion.

JonasUJ commented 4 years ago

I wish there was a more Pythonic way to write this

I feel you and I actually didn't mean for it to be like that. I saw that I redefined handle_event on every iteration, and without even thinking more about it moved it above the loop. If i had noticed the hide() and show() calls in the function, I wouldn't have expected this to work, but since it did I actually didn't notice this horror before you pointed it out.

lemonsaurus commented 4 years ago

I wish there was a more Pythonic way to write this

I feel you and I actually didn't mean for it to be like that. I saw that I redefined handle_event on every iteration, and without even thinking more about it moved it above the loop. If i had noticed the hide() and show() calls in the function, I wouldn't have expected this to work, but since it did I actually didn't notice this horror before you pointed it out.

So, callbacks will have access to this, right, but would element be available then inside this? In that case, we could just define show and hide at the top, they can take element as a parameter, and handle_event can grab element from this and pass it into the function calls?

I'm not sure that will work but.. maybe?

EDIT: I'm concerned this would not work because you'd just get the final element in the iteration instead of the specific element that we were iterating when the callback was bound.

JonasUJ commented 4 years ago

The sad thing is that if they just included this one CSS rule in Bulma, it would have almost the same behaviour and there would be no need for 40 lines of js

.dropdown:not(.is-hoverable) .dropdown-trigger:focus-within + .dropdown-menu {
    display: block;
}
lemonsaurus commented 4 years ago

The sad thing is that if they just included this one CSS rule in Bulma, it would have almost the same behaviour and there would be no need for 40 lines of js

Bulma is quite receptive to pull requests - you could always open one to them and see what jgthms says?

Looks like similar stuff has been merged in the past.