There's an API call or something with a progress bar. A screen reader user will have no idea of anything that is happening on the screen right now. And that's what we're going to fix.
How are we going to fix it? We're actually going to use something called LiveRegion. LiveRegion is not invented by a framework. It's actually something that is available in HTML. LiveRegion is a part of the page that is going to be read out on a screen reader every time its content changes. Luckily for us, we don't have to actually implement all different LiveRegion around, but there is a plugin that is called ViewAnnouncer that is actually going to do the heavy work for us. So after we set it up, you will see that it's going to be very easy to actually use the LiveRegion whenever we need. So let's go over in the Hub, and let's start to set it up together.
So this is our application. It's a very simple one. As I said, we have the three components here. We have the welcome page, and we have the default layout. To add the LiveRegion, the first step is to actually add the package. The package is called announcer, and because we're using the View3, we're going to go do the announcer at next for the View3 version. So after adding the plugin, I'm going on the screen so I can get things and actually be fast for the talk. After we add the package, we're going to go on a main.js file, and we're going to put it at the very top, and next, we're actually going to import the style, so that the announcer needs to make sure that the component is not actually displayed, so there's some styles necessary as well for it to be done. And lastly, on this file, we're going to go down below, and we're going to make sure that we actually add the plugin. So, this is our application. Step one, done.
The next thing we have to do before we can actually use it is we need to add this component, so you could add this component on every single file that you want to use it, but I do suggest to actually add it in a layout. So as you can see, I have my main layout with the nav bar in the main, so I'm going to add the ViewAnnouncer on the very top of this page. Lastly, we're going to actually use the ViewAnnouncer and we're going to do it on our dynamic data. So if you open up the dynamic data file, you can see that on the very top we have a loading that is referenced to zero, we have a fake loader, so this increased to 25 every second and at the very end, we're going to set names that actually going to set the names. Before actually changing here, we're going to go into application and see what the screen reader actually reads out to us. So we go back here, I'm going to switch my screen reader on. So you should be able, you should be able to actually see the caption over here. So if we go on dynamic data and we click the load data. As you can see, the screen reader is saying absolutely nothing.
Comments