A recipe site opens a filter panel from a Filter recipes button. Use a native dialog and open it with showModal() so keyboard users can work inside it while the rest of the page is inert. Give the dialog a heading and connect it with aria-labelledby. In this panel the first checkbox is a reasonable starting point, so put autofocus on that control.
Add a visible Cancel control. Inside the dialog, a button in a form with method="dialog" can close it without submitting a request. Keep any code that applies the filter on the affirmative action and give that action a different button name so the test can distinguish it from Cancel.
Run the whole interaction without a pointer
Focus Filter recipes with Tab and open it with Enter. Check that focus lands inside the panel at the intended control. Tab through the controls and verify that page content behind the panel stays unreachable. Press Escape and check that the modal closes, focus returns to the opening button, and the result list is unchanged. Repeat with the Cancel button. Finally, apply a new filter and confirm the results update after the panel closes.
Separate a canceled draft from an applied filter
Start with an unfiltered list and a checkbox such as Vegetarian. Open the dialog, change the checkbox with Space, then press Escape. Confirm the panel closes and the results still show the original count. Open it again to check whether the controls represent the current applied state. If an abandoned draft still appears, check how the dialog initializes its controls each time it opens.
Do the same through the Apply button. The count should reflect the selected filter and the opening button should be reachable immediately afterward. Try Shift+Tab inside the open dialog as well as forward Tab.
