Repository navigation
fix(Offcanvas): in-place panel stays interactive, focus returns on close - #284
Merged
Merged
Conversation
role and aria-modal only while open; inert only for a closed panel (computed position fixed), re-read after render and on resize; hiding class only for a real hide; focus trap enabled only while open, no auto-capture.
…irst On close or destroy while open, focus goes to the cOffcanvasToggle that opened the offcanvas, else to the element focused when it opened; only when focus is inside the offcanvas or on body, and skipping a target that is detached or cannot take focus.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A closed offcanvas that CSS lays out in place (
responsivefrom its breakpoint up,.navbar-expand-* .offcanvasfrom the expand breakpoint up) was visible but dead: the host keptinert,role="dialog",aria-modal="true"and thehidingclass from the first render, so nothing inside could be clicked or focused and screen readers announced a modal dialog. The dropdown in the dark navbar example did not open for that reason.roleandaria-modalare rendered only while the offcanvas is open, as in the vanilla edition.inertis dropped from a closed offcanvas once its computed position is read and is notfixed; until the first read, and on the server, it stays as before. The position is re-read after every render and on window resize. Thehidingclass is added only when an open offcanvas closes. The focus trap is enabled only while open and no longer auto-captures focus at init, which would have moved focus into an in-place panel on page load; opening focuses the offcanvas host as before.An open offcanvas that was shown as a fixed panel is closed when a window resize lays it out in place, as in the vanilla edition. An offcanvas in
.navbar-expand-*opened on a narrow window no longer stays a modal dialog with a backdrop after the window is widened. One that was never a fixed panel, for example keptposition-absoluteby author CSS, stays open, so a mobile soft keyboard does not close it. Withportalthe offcanvas sits in the container while open, stays a fixed panel and is not closed.On close, and when an open offcanvas is destroyed, focus returns to the
cOffcanvasTogglethat opened it, else to the element focused when it opened. It moves only while focus is inside the offcanvas or on the body, and skips a target that is detached or cannot take focus. Returning to the toggle covers Safari, where clicking a button does not focus it. Docs: coreui/coreui-angular-docs branch fix/offcanvas-in-place.