Skip to content
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

v4: Cannot use input of a popover inside modal #22249

Closed
nunofilipesf opened this issue Mar 23, 2017 · 18 comments
Closed

v4: Cannot use input of a popover inside modal #22249

nunofilipesf opened this issue Mar 23, 2017 · 18 comments
Labels

Comments

@nunofilipesf
Copy link

nunofilipesf commented Mar 23, 2017

I've tried to create a modal with a popover inside.
This popover has html content with an input and a select.

If i open the modal and the popover, i can use the select, but not the input.
Also, the focus is not on the input.

Sample here: https://jsfiddle.net/bpx3zsyz/2/

Tested in Chrome, Edge and Firefox, always with the same behaviour

@gsferreira
Copy link

👍

@satyajit11
Copy link

remove tabindex="-1" of your modal it'll work.put the below line without tabindex

here is example fiddle
jsfiddle

@Johann-S
Copy link
Member

IMO @satyajit11 give a correct answer (see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex).

I'm not sure it's a Bootstrap bug here, any advice @mdo or @bardiharborow ?

@mdo
Copy link
Member

mdo commented Mar 23, 2017

Our docs include tabindex="-1"—do we need to update to fix that on our end, or is there JS to tackle?

@satyajit11
Copy link

satyajit11 commented Mar 24, 2017

@Johann-S when add popover code it is append to body which is outside modal because we already have tabindex="-1" so focus won't go there.I don't proper js solution but i think we need to append inside the container or remove focus from modal when we add popover

@nunofilipesf
Copy link
Author

nunofilipesf commented Mar 24, 2017

Removing the tabindex from the modal solved my problem.
Thanks for the help!

Can i close the issue or there is here a bug in Bootstrap to solve?

@Johann-S Johann-S added the docs label Mar 24, 2017
@Johann-S
Copy link
Member

As @mdo said we should update our documentation and remove tabindex="-1" reference.
@nunofilipesf we have to update our documentation

@patrickhlauke
Copy link
Member

removing the tabindex=-1 on the modal is NOT the solution. or rather: once you remove this, the modal cannot be programmatically focused by javascript when it's opened, meaning that accessibility for the modal is broken (screen reader doesn't announce there's a modal, doesn't read the title of the modal).

i'd suggest the problem is in the popup and the way it's generated, rather than the modal itself.

@Johann-S
Copy link
Member

Johann-S commented Mar 24, 2017

When #22263 will be merged @nunofilipesf you'll have to update your code to the following by adding
container attribute which specify the parent node of the modal + update your version of Tether to 1.4.0 and your input will be selectable

    $(document).ready(function () {
    	var popoverContent = '<div> \
                                    <select class="form-control mb-1"> \
                                        <option value="eq">Is equal to</option>  \
                                        <option value="ct">Contains</option> \
                                    </select> \
                                    <input type="text" class="form-control"> \
                                </div>';
    
    	$('#exampleModalLong').on('shown.bs.modal', function (e) {
    		var popover = $('#popover-btn').popover({
    			title: '',
    			placement: 'bottom',
    			html: true,
    			content: popoverContent,
    			trigger: 'manual',
                container : '#exampleModalLong'
    		});
    	});
    
    	$('#popover-btn').click(function () {
    		$(this).popover('show');
    	});
    

@DavidEmanuelsen
Copy link

I tried this with the changes in the pull-request + tether 1.4.0. Tried adding an id to the modal-element and using that as the container, but I'm having issues with the position of the popover as soon as there is a scrollbar / long content in the modal. Seems like the popover moves twice as much as it should on the y-axis.

Is this something known, or am I doing something horribly wrong? :)

@Johann-S
Copy link
Member

Please @DavidEmanuelsen post a JSBin or a CodePen to see your issue thank you

@DavidEmanuelsen
Copy link

https://jsfiddle.net/w8yh65cr/3/

Slightly ugly jsfiddle, not sure how to reference bootstrap including the changes you've made.

@Johann-S
Copy link
Member

It seems Tether determine position of the popover according to the scroll position 🤔

@FezVrasta
Copy link
Contributor

FezVrasta commented Apr 5, 2017

The "append" option of Tether accepts only an element that is identical to body, nothing different. (same size, same position, same everything).

This, and lot of different problems, were the reason that convinced me in opening this PR:
#19673

More info at shipshapecode/tether#204

@Johann-S
Copy link
Member

Closed and fixed by #22444

@trinaldi
Copy link

trinaldi commented Nov 7, 2017

As of today, with the newest version, I'm still experiencing this issue.

@dersar00
Copy link

I'm still experiencing this issue too, v4.3.1.

@Johann-S
Copy link
Member

Hi @dersar00,

It seems related to your code because you have a live example which work here: https://getbootstrap.com/docs/4.3/components/modal/#tooltips-and-popovers

Anyway it's pointless to comment on a closed issue, if you have an issue open a new one with a live test example 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants