<commit_before>import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { iconCaretDown } from 'carbon-icons';
import Icon from '../Icon';

const Select = ({
  className,
  id,
  inline,
  labelText,
  disabled,
  children,
  iconDescription,
  hideLabel,
  invalid,
  invalidText,
  helperText,
  light,
  ...other
}) => {
  const selectClasses = classNames({
    'bx--select': true,
    'bx--select--inline': inline,
    'bx--select--light': light,
    [className]: className,
  });
  const labelClasses = classNames('bx--label', {
    'bx--visually-hidden': hideLabel,
  });
  const errorId = `${id}-error-msg`;
  const error = invalid ? (
    <div className="bx--form-requirement" id={errorId}>
      {invalidText}
    </div>
  ) : null;
  const helper = helperText ? (
    <div className="bx--form__helper-text">{helperText}</div>
  ) : null;
  return (
    <div className="bx--form-item">
      <div className={selectClasses}>
        <label htmlFor={id} className={labelClasses}>
          {labelText}
        </label>
        <select
          {...other}
          id={id}
          className="bx--select-input"
          disabled={disabled || undefined}
          data-invalid={invalid || undefined}
          aria-invalid={invalid || undefined}
          aria-describedby={invalid && errorId}>
          {children}
        </select>
        <Icon
          icon={iconCaretDown}
          className="bx--select__arrow"
          description={iconDescription}
        />
        {helper}
        {error}
      </div>
    </div>
  );
};

Select.propTypes = {<commit_msg>fix: We are no longer including the aria-describedby if it is false, resolves #1367. (#1368)<commit_after>import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { iconCaretDown } from 'carbon-icons';
import Icon from '../Icon';

const Select = ({
  className,
  id,
  inline,
  labelText,
  disabled,
  children,
  iconDescription,
  hideLabel,
  invalid,
  invalidText,
  helperText,
  light,
  ...other
}) => {
  const selectClasses = classNames({
    'bx--select': true,
    'bx--select--inline': inline,
    'bx--select--light': light,
    [className]: className,
  });
  const labelClasses = classNames('bx--label', {
    'bx--visually-hidden': hideLabel,
  });
  const errorId = `${id}-error-msg`;
  const error = invalid ? (
    <div className="bx--form-requirement" id={errorId}>
      {invalidText}
    </div>
  ) : null;
  const helper = helperText ? (
    <div className="bx--form__helper-text">{helperText}</div>
  ) : null;
  const ariaProps = {};
  if (invalid) {
    ariaProps['aria-describedby'] = errorId;
  }
  return (
    <div className="bx--form-item">
      <div className={selectClasses}>
        <label htmlFor={id} className={labelClasses}>
          {labelText}
        </label>
        <select
          {...other}
          {...ariaProps}
          id={id}
          className="bx--select-input"
          disabled={disabled || undefined}
          data-invalid={invalid || undefined}
          aria-invalid={invalid || undefined}>
          {children}
        </select>
        <Icon
          icon={iconCaretDown}
          className="bx--select__arrow"
          description={iconDescription}
        />
        {helper}
        {error}
      </div>
    </div>
  );
};

Select.propTypes = {
{'fraction_non_alphanumeric': 0.1535294117647059, 'fraction_numerical': 0.002352941176470588, 'mean_word_length': 2.41123370110331, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2623882', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1023, 'n_words': 223}