select2 in an unpoly v2 layer

66 views
Skip to first unread message

scott....@gmail.com

unread,
May 11, 2021, 9:16:05 PM5/11/21
to unpoly
In unpoly v1 I had a compiler to build out a select2 widget:


You have to pass an option to attach the select2 widget to the modal instead of the body because:

"This issue occurs because Bootstrap modals tend to steal focus from other elements outside of the modal" [1]

In unpoly v2 I updated this line:

var $modal = $(".up-modal-content");

to: 

var $modal = $("up-drawer-content");

 but the select2 instantiation doesn't get attached to the $modal like it did in v1.

Any thoughts?

Henning Koch

unread,
May 12, 2021, 6:51:07 AM5/12/21
to unp...@googlegroups.com
> In unpoly v2 I updated this line:
>
> var $modal = $(".up-modal-content");
>
> to:
>
> var $modal = $("up-drawer-content");

This looks correct in case you're opening an overlay with the "drawer"
mode. If you're using the "modal" mode you need to select
'up-modal-content'.

You might want to add a `debugger` statement before the line to see if
you're selecting the content element as expected.

> "This issue occurs because Bootstrap modals tend to steal focus from
> other elements outside of the modal" [1]

Just FYI: This is an accessibility feature. To support screen readers
focus must be trapped within a modal overlay. Unpoly 2 does the same.

Best regards
Henning
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages