Dialog-position

In this video, I discuss the challenges we face with keyboard accessibility in modal dialogs and introduce a new dialog-position package on NPM, that exposes a stylesheet to easily position native HTML <dialog> elements.

Loom: Enhancing Modal Dialog Accessibility

1

Hi, so I wanted to talk to you today about

2

the, about modal dialogs and about

3

the dialog-position package that was recently published

4

on the NPM website. Registry, and you can see it there.

5

So we often, as accessibility consultants,

6

we often come across problems with,

7

with keyboard, accessibility in relation to,

8

in relation to modal dialogs,

9

either things like the focus not being moved into a modal dialog,

10

when it’s, when it’s opened, or that focus is not restricted

11

to the modal dialog. or indeed when we close the dialog,

12

focus is not returned to the triggering element.

13

and so,

14

in the past, or, you know,

15

in the recent past, we would have had to rely on quite

16

a lot of ARIA and quite a lot of Javascript,

17

to Good. So here’s the APG,

18

version that uses 330 lines to

19

implement a modal dialog, and 330 lines of JavaScript,

20

and so, obviously, it’s quite a challenge, and it’s quite a challenge to

21

try to get things right, and it’s quite a challenge to make things, to

22

make the modal dialog accessible,

23

but fortunately, it’s certainly now, we have the native,

24

eh, eh, eh, native element,

25

HTML, HTML, native, eh, eh, eh, eh, eh, eh,

26

eh, native element. And that, erm, does a lot of the

27

heavy lifting for us,

28

so it’s, it’s very, it’s very good at managing

29

the focus of the keyboard.

30

In the way that we want,

31

and indeed, it is now widely supported.

32

So it’s supported, erm, it says on,

33

on this website, on this website. And I use,

34

it’s supported by around, erm, I have 96% of,

35

erm, I have 96% of browsers globally.

36

Which is pretty good. Erm, the one

37

thing that the term people might be asking now is how,

38

how to, Why you position, erm,

39

how I push the native dialog,

40

erm, on the page. Erm, it is,

41

erm, it uses the CSS fixed,

42

erm, fixed.

43

Fixed, eh,

44

Position. Er, and so, erm, I went to this research, erm,

45

and came up with quite a,

46

Erm, simple, erm, CSS style sheet.

47

Here we are, it’s only 50 lines long.

48

Erm, and that allows you to position,

49

based on a data attribute.

50

Erm, so a data-position attribute.

51

Erm, these are the sort of values that you expect,

52

so top, bottom, left, right. And those results,

53

in full height and full with modal modals.

54

And then you can also use things like top,

55

hyphen, left, top, hyphen, right.

56

Bottom, hyphen, left, bottom,

57

hyphen, right. As well.

58

So, there you go.

59

this is, erm, and here’s a basic sort of demo that I put together,

60

er, that uses this style sheet.

61

As you can see, as you move,

62

as you click on the buttons, and

63

it moves the modal dialog around the screen by

64

setting this data attribute.

65

So, really, that’s, hopefully, that’s really

66

handy, and would be a really useful tool for people building websites, and want

67

to, make sure they’re accessible.

'SM' comments disabled.

'ID' comments disabled.