diff --git a/src/components/SegmentedControl.js b/src/components/SegmentedControl.js index 6a12783c2..6319330a7 100644 --- a/src/components/SegmentedControl.js +++ b/src/components/SegmentedControl.js @@ -1,5 +1,6 @@ import React, { useState } from 'react'; import PropTypes from 'prop-types'; +import { css } from '@emotion/react'; const get = (x, key) => Object.prototype.hasOwnProperty.call(x, key) ? x[key] : x; @@ -8,7 +9,52 @@ const SegmentedControl = ({ items, onChange }) => { const [selected, setSelected] = useState(get(items[0], 'value')); return ( -
+
{items.map((item, index) => { const value = get(item, 'value'); @@ -21,6 +67,7 @@ const SegmentedControl = ({ items, onChange }) => { aria-pressed={selected === value} disabled={item.disabled} onClick={(e) => { + if (item.disabled) return; setSelected(value); onChange && onChange(e, value); }}