0Pricing
Web Accessibility Academy · درس

إدارة roving tabindex في الأدوات

اسمحوا لمفاتيح الأسهم بالتنقل داخل عنصر تحكم مركب

إدارة roving tabindex في الأدوات درس مجاني في Web Accessibility Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Web Accessibility Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Web Accessibility Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

One Stop for a Whole Widget

In a toolbar or radio group, Tab should reach the widget once, not every item. Roving tabindex is the pattern that makes this work.

The Core Idea

Exactly one item holds tabindex="0" at a time. Every other item gets tabindex="-1", so Tab enters the group at a single point.

Initial Setup

On load, give the first or selected item tabindex="0" and set the rest to tabindex="-1". That is the resting state of the group.

<button tabindex="0">Bold</button>
<button tabindex="-1">Italic</button>

Arrow Keys Move Within

Once focus is inside, the user moves between items with the arrow keys, not Tab. Tab still exits the whole widget.

The Roving Step

On an arrow press you do two things: set the old item to -1 and the new item to 0, then call focus() on the new one. 🧭

old.tabIndex = -1;
next.tabIndex = 0;
next.focus();

Why Only One Zero

Keeping a single tabindex="0" means Tab always lands on the item the user last used, so returning to the widget feels natural.

Match the APG Pattern

The ARIA Authoring Practices Guide specifies the exact keys for each widget. Follow its keyboard map rather than inventing one.

Optional Wrapping

Many widgets wrap arrow movement: pressing right on the last item loops to the first. Check the APG for whether your pattern should wrap.

Home and End Too

Composite widgets often add Home and End to jump to the first and last items, a small touch that speeds up navigation.

Roving vs aria-activedescendant

Roving tabindex moves real DOM focus. The alternative, aria-activedescendant, keeps focus on a container and points to a virtual active item.

Test the Whole Cycle

Tab in, arrow through every item, Tab back out, then Tab in again and confirm focus returns to the last-used item.

Quick Check

In a roving tabindex toolbar, how many items have tabindex="0" at any moment?

Recap

You mastered roving tabindex: one item at 0, the rest at -1, arrow keys rove the 0 between them, and Tab moves past the whole widget. 🚀

الأسئلة الشائعة

هل درس «إدارة roving tabindex في الأدوات» مجاني؟

نعم — نص درس «إدارة roving tabindex في الأدوات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Web Accessibility Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Web Accessibility Academy 4 دروس في المجموع.

ماذا ستتعلم في «إدارة roving tabindex في الأدوات»؟

اسمحوا لمفاتيح الأسهم بالتنقل داخل عنصر تحكم مركب تتمرن على Web Accessibility Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Web Accessibility Academy؟

لا تُشترط خبرة سابقة. Web Accessibility Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «إدارة roving tabindex في الأدوات»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Web Accessibility Academy هذا؟

نعم. كل درس في Web Accessibility Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. tabindex ‏0 و-1، وعدم استخدام القيم الموجبة
  2. نقل التركيز بعد تنفيذ إجراء
  3. إعادة التركيز عند إغلاق طبقة
  4. إدارة roving tabindex في الأدوات
← العودة إلى Web Accessibility Academy