diff --git a/packages/tabs/README.md b/packages/tabs/README.md index 051369b6..34ab453b 100644 --- a/packages/tabs/README.md +++ b/packages/tabs/README.md @@ -64,6 +64,14 @@ const [ instance ] = tabs(elements); } ``` +## Setting the active tab +``` +On page load the active tab will be set by (in order of precedence): +1. The page hash. If the page hash in the address bar matches the ID of a panel, it will be activated on page load +2. The data-active-index attribute. If the tabs node found to have a
data-active-indexattribute, that tab will be activated on page load. This is a zero-based index. +3. The tab specified by the activeIndex in the settings. This is a zero-based index. +4. The first tab in the set. + ## API tabs() returns an array of instances. Each instance exposes the interface diff --git a/packages/tabs/__tests__/unit/utils.js b/packages/tabs/__tests__/unit/utils.js index 21fb38a8..8e783255 100644 --- a/packages/tabs/__tests__/unit/utils.js +++ b/packages/tabs/__tests__/unit/utils.js @@ -1,4 +1,4 @@ -import { getActiveIndexByHash } from '../../src/lib/utils'; +import { getActiveIndexByHash, getActiveIndexOnLoad } from '../../src/lib/utils'; const init = () => { document.body.innerHTML = `