Skip to content

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

Closed

Description

@nunofilipesf

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

Activity

  1. gsferreira commented on Mar 23, 2017

    @gsferreira

    👍

  2. satyajit11 commented on Mar 23, 2017

    @satyajit11

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

    here is example fiddle
    jsfiddle

  3. added
    jsJavaScript or TypeScript sources and plugins
    v4v4, the frozen docs on gh-pages
    on Mar 23, 2017
  4. Johann-S commented on Mar 23, 2017

    @Johann-S
    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 ?

  5. mdo commented on Mar 23, 2017

    @mdo
    Member

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

  6. satyajit11 commented on Mar 24, 2017

    @satyajit11

    @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

  7. nunofilipesf commented on Mar 24, 2017

    @nunofilipesf
    Author

    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?

  8. added
    docsDocumentation site and its content
    on Mar 24, 2017
  9. Johann-S commented on Mar 24, 2017

    @Johann-S
    Member

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

  10. patrickhlauke commented on Mar 24, 2017

    @patrickhlauke
    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.

  11. removed
    docsDocumentation site and its content
    on Mar 24, 2017
  12. Johann-S commented on Mar 24, 2017

    @Johann-S
    Member

    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');
        	});
        
  13. DavidEmanuelsen commented on Mar 29, 2017

    @DavidEmanuelsen

    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? :)

  14. Johann-S commented on Mar 29, 2017

    @Johann-S
    Member

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

  15. DavidEmanuelsen commented on Mar 29, 2017

    @DavidEmanuelsen

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

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

  16. Johann-S commented on Mar 29, 2017

    @Johann-S
    Member

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

  17. FezVrasta commented on Apr 5, 2017

    @FezVrasta
    Contributor

    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

  18. Johann-S commented on May 14, 2017

    @Johann-S
    Member

    Closed and fixed by #22444

  19. trinaldi commented on Nov 7, 2017

    @trinaldi

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

  20. dersar00 commented on May 17, 2019

    @dersar00

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

  21. Johann-S commented on May 17, 2019

    @Johann-S
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    jsJavaScript or TypeScript sources and pluginsv4v4, the frozen docs on gh-pages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions