Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop generateId support #287

Merged
merged 1 commit into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/elements/forms/text-field.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Control from './control'
import Addon from './addon'
import styles from './text-field.css'

import { classNames, generateId } from 'utils'
import { classNames } from 'utils'

/**
* Unique ID generator
Expand Down Expand Up @@ -44,7 +44,7 @@ const TextField = React.forwardRef(
(
{
children,
id = generateId(),
id,
className,
label,
helper,
Expand Down Expand Up @@ -117,10 +117,8 @@ TextField.propTypes = {
/**
* An ID that will be used to link input and label. It's necessary for
* accessibility.
*
* If not passed, it will be generated automatically using a random string.
*/
id: PropTypes.string,
id: PropTypes.string.isRequired,
/**
* Helper message to show bellow the input
*/
Expand Down
9 changes: 7 additions & 2 deletions src/modules/select/select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { useInput, useOptions } from './hooks'
import styles from './select.css'

import { Form, Icon, Button } from 'elements'
import { classNames, generateId } from 'utils'
import { classNames } from 'utils'

const Select = React.memo(
({
id,
value,
onInput,
onChange,
Expand All @@ -21,7 +22,6 @@ const Select = React.memo(
clearButton = true,
clearOnFocus = false,
tag: Tag = 'div',
id = generateId(),
...restInputProps
}) => {
// custom select hooks
Expand Down Expand Up @@ -150,6 +150,11 @@ const Select = React.memo(
)

Select.propTypes = {
/**
* An ID that will be used to link input and label. It's necessary for
* accessibility.
*/
id: PropTypes.string.isRequired,
/* Label to show in input */
label: PropTypes.string.isRequired,
/* The current value shown in input field */
Expand Down
3 changes: 1 addition & 2 deletions src/modules/select/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const SelectExample = () => {
const [suggestions, setSuggestions] = React.useState(options)
const [value, setValue] = React.useState('Default option')
const [value, setValue] = React.useState('')

const handleOnChange = (data) => {
// trigger search here
Expand All @@ -36,7 +36,6 @@
id="select-1"
value={value}
label="Search"
variant="pure"
onChange={handleOnChange}
onInput={handleOnInput}
placeholder="e.g. article title or author name"
Expand Down
1 change: 0 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * as classNames from './class-names'
export generateId from './unique-id'
3 changes: 0 additions & 3 deletions src/utils/unique-id.js

This file was deleted.