mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-12-02 23:52:22 +03:00
TabsInternal.V2 supports a disabled
attribute
Disabled tabs can't be selected and will be skipped when navigating tabs with the keyboard.
This commit is contained in:
parent
e7c4d8d3bf
commit
346550f96f
@ -206,6 +206,7 @@ view config =
|
||||
, tabView = [ viewIcon option.icon, option.label ]
|
||||
, panelView = option.content
|
||||
, spaHref = Maybe.map (\toUrl -> toUrl option.value) config.toUrl
|
||||
, disabled = False
|
||||
}
|
||||
|
||||
{ tabList, tabPanels } =
|
||||
|
@ -44,6 +44,7 @@ type alias Tab id msg =
|
||||
, tabView : List (Html msg)
|
||||
, panelView : Html msg
|
||||
, spaHref : Maybe String
|
||||
, disabled : Bool
|
||||
}
|
||||
|
||||
|
||||
@ -59,6 +60,7 @@ fromList { id, idString } attributes =
|
||||
, tabView = []
|
||||
, panelView = Html.text ""
|
||||
, spaHref = Nothing
|
||||
, disabled = False
|
||||
}
|
||||
in
|
||||
List.foldl (\applyAttr acc -> applyAttr acc) defaults attributes
|
||||
@ -125,6 +127,7 @@ viewTab_ config index tab =
|
||||
++ tagSpecificAttributes
|
||||
++ tab.tabAttributes
|
||||
++ [ Attributes.tabindex tabIndex
|
||||
, Attributes.disabled tab.disabled
|
||||
, Widget.selected isSelected
|
||||
, Role.tab
|
||||
, Attributes.id (tabToId tab.idString)
|
||||
@ -160,7 +163,13 @@ keyEvents { focusAndSelect, tabs } thisTab keyCode =
|
||||
acc
|
||||
|
||||
( True, Nothing ) ->
|
||||
( True, Just { select = tab.id, focus = Just (tabToId tab.idString) } )
|
||||
( True
|
||||
, if tab.disabled then
|
||||
Just { select = tab.id, focus = Just (tabToId tab.idString) }
|
||||
|
||||
else
|
||||
Nothing
|
||||
)
|
||||
|
||||
( False, Nothing ) ->
|
||||
( tab.id == thisTab.id, Nothing )
|
||||
|
Loading…
Reference in New Issue
Block a user