-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Various fixes for Modals #326
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
Conversation
* Create form-input-static.vue New form-static input * Added form-input-static compoinent * Refactored static input Refactored to use the new `<b-form-input-static>` component * Switch to bFormInputStatic Updated child component var to bFormInputStatic to follow proper naming conventions * Removed lazyFormatter from static-input * Added trailing semi-colon To make CircleCI happy * Added missing 'this' * [nav-item] add dropdown class * Added <slot> for robustness * new b-form-input-static component (#292) * Create form-input-static.vue New form-static input * Added form-input-static compoinent * Refactored static input Refactored to use the new `<b-form-input-static>` component * Switch to bFormInputStatic Updated child component var to bFormInputStatic to follow proper naming conventions * Removed lazyFormatter from static-input * Added trailing semi-colon To make CircleCI happy * Added missing 'this' * Added <slot> for robustness * fixed missing `.vue` extension on import * Added missing extension on component import (#293) * Optimized import order in form-input.vue (#294) * Added missing extension on component import * Optimized import order
Resync with master
Resync with master
Resync with master
Ensures that the first focusable item in the modal is focused when it is shown. When selecting the item to focus: - First looks in footer - Then body - Then header - Else focus the modal itself Also included generate-id mixin for ARIA labeling
Changed from listing for focus to focusin for enforceFocus hanlder
enforceFocus event listeners are now only instantiated when the modal is shown.
Added a second optional argument to the `show::modal` event to allow specifying the element (i.e. button, link) to return focus to when Modal closes.
Allow to return focus to triggering element when modal is closed.
added in prop `returnFocus` to specify element to re-focus to when modal closes. Accepts either a CSS selector string (i.e. '#mybutton') or an `HTMLElement` reference. If CSS selector string matches more than one element, then only the first element is re-focused.
lib/components/modal.vue
Outdated
export default { | ||
mixins: [generateId], |
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.
generateId
usage should be limited to inputs only as is mentioned inside Mixin. Also as of vue 2.3.x we can not trust _uid
because they are inconsistent between client server in SSR mode. See here
_uid is internal and should not be used as part of the application state
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.
Ah, yes. I'll remove that, and make sure aria-labeledby
and aria-describedby
don't get set if the ID is missing.
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.
Thanks @tmorehouse that's so sad that we currently can't have such behavior. I'll make an on/off switch for generateId
s so non-ssr users can use them optionally until we can find better way generating consistent IDs :)
`aria-labelledby` and `aria-describedby` will not be present (by setting bound attribute to null) if an `id` is not specified for the modal.
Take a new look over, I think I have removed all generate-id references (including |
Various fixes & tweaks:
onEsc
issue where hittingESC
and the modal wasn't clicked initially (focused), the modal wouldn't close (see discussion at Added closeOnEsc, hideHeaderClose & enforceFocus #247), by ensuring that an element within the modal (or the modal itself) is focused when modal opens (using$nextTick
)enforceFocus
handler, and only instantiate it when the modal is open (removes it when closed),returnFocus
) to the original element that triggered the modal opening. Works with thev-b-modal
directive automatically (i.e. the element with thev-b-modal
directive), or can be specified as a propreturn-focus
. Can be a CSS selector string (i.e.'#mybutton'
or anHTMLElement
reference).generate-id
mixin, in case the modal doesn't have an ID, foraria-labeledby
andaria-describedby
cross referencing.For the initial focus on modal open, the modal content is searched for the first focusable element, and if not found defaults to the modal itself. When searching for focusable elements, the following order is used: