Skip to content

Commit

Permalink
Merge pull request #411 from bestguy/modalFixes
Browse files Browse the repository at this point in the history
Modal fixes
  • Loading branch information
bestguy authored Jan 1, 2022
2 parents c69b9ef + 803232b commit bdbb889
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import {
conditionallyUpdateScrollbar,
getOriginalBodyPadding,
setScrollbarWidth
setScrollbarWidth,
uuid
} from './utils';
const dispatch = createEventDispatcher();
Expand All @@ -40,7 +41,7 @@
export let scrollable = false;
export let size = '';
export let toggle = undefined;
export let labelledBy = '';
export let labelledBy = header ? `modal-${uuid()}` : undefined;
export let backdrop = true;
export let wrapClassName = '';
export let modalClassName = '';
Expand Down Expand Up @@ -226,7 +227,7 @@
<div
in:modalIn
out:modalOut
ariaLabelledby={labelledBy}
aria-labelledby={labelledBy}
class={classnames('modal', modalClassName, {
fade,
'position-static': staticModal
Expand All @@ -243,7 +244,7 @@
<div class={classes} role="document" bind:this={_dialog}>
<div class={classnames('modal-content', contentClassName)}>
{#if header}
<ModalHeader {toggle}>
<ModalHeader {toggle} id={labelledBy}>
{header}
</ModalHeader>
{/if}
Expand Down
10 changes: 9 additions & 1 deletion src/ModalBackdrop.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
<script>
// TODO only allow single backdrop open at once.
import { onMount } from 'svelte';
import classnames from './utils';
import { backdropIn, backdropOut } from './transitions.js';
let className = '';
export { className as class };
export let isOpen = false;
export let fade = true;
let loaded = false;
onMount(() => {
loaded = true;
});
$: classes = classnames(className, 'modal-backdrop');
</script>

{#if isOpen}
{#if isOpen && loaded}
<div
{...$$restProps}
on:click
Expand Down
3 changes: 2 additions & 1 deletion src/ModalHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
export let toggle = undefined;
export let closeAriaLabel = 'Close';
export let children = undefined;
export let id = undefined;
$: classes = classnames(className, 'modal-header');
</script>

<div {...$$restProps} class={classes}>
<h5 class="modal-title">
<h5 class="modal-title" id={id}>
{#if children}
{children}
{:else}
Expand Down
4 changes: 2 additions & 2 deletions src/Tooltip.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
$: if (target) {
unregisterEventListeners();
registerEventListeners();
};
}
function registerEventListeners() {
Expand All @@ -70,7 +70,7 @@
targetEl.addEventListener('focus', open);
targetEl.addEventListener('blur', close);
}
};
}
function unregisterEventListeners() {
if (targetEl) {
Expand Down

0 comments on commit bdbb889

Please sign in to comment.