patternfly-react icon indicating copy to clipboard operation
patternfly-react copied to clipboard

React does not recognize the createText and noResultsFoundText prop in SelectMenu

Open kzolti opened this issue 7 years ago • 2 comments

I Use the Pf4 Select componet example from https://www.patternfly.org/v4/documentation/react/components/select/ When I click the selct it gives me warnings.

my packages:

"@patternfly/react-core": "^3.112.3", "@patternfly/react-icons": "^3.14.12", "@patternfly/react-styles": "^3.5.27", "@patternfly/react-table": "^2.22.19", ... "react": "^16.11.0", "react-dom": "^16.11.0"

My code:

import React from 'react';
import { CubeIcon } from '@patternfly/react-icons';
import { Select, SelectOption, SelectVariant, Checkbox } from '@patternfly/react-core';

class SingleSelectInput extends React.Component {
  constructor(props) {
    super(props);
    this.options = [
      { value: 'Choose...', disabled: false, isPlaceholder: true },
      { value: 'Mr', disabled: false },
      { value: 'Miss', disabled: false },
      { value: 'Mrs', disabled: false },
      { value: 'Ms', disabled: false },
      { value: 'Dr', disabled: false },
      { value: 'Other', disabled: false }
    ];

    this.state = {
      isToggleIcon: false,
      isExpanded: false,
      selected: null,
      isDisabled: false,
      direction: SelectDirection.down
    };

    this.onToggle = isExpanded => {
      this.setState({
        isExpanded
      });
    };

    this.onSelect = (event, selection, isPlaceholder) => {
      if (isPlaceholder) this.clearSelection();
      else {
        this.setState({
          selected: selection,
          isExpanded: false
        });
        console.log('selected:', selection);
      }
    };

    this.clearSelection = () => {
      this.setState({
        selected: null,
        isExpanded: false
      });
    };

    this.toggleDisabled = (checked) => {
      this.setState({
        isDisabled: checked
      })
    }

    this.setIcon = (checked) => {
      this.setState({
        isToggleIcon: checked
      })
    }

    this.toggleDirection = () => {
      if(this.state.direction === SelectDirection.up) {
        this.setState({
          direction: SelectDirection.down
        });
      } else {
        this.setState({
          direction: SelectDirection.up
        })
      }
    }
  }

  render() {
    const { isExpanded, selected, isDisabled, direction, isToggleIcon } = this.state;
    const titleId = 'title-id';
    return (
      <div>
        <span id={titleId} hidden>
          Title
        </span>
        <Select
          toggleIcon={isToggleIcon && <CubeIcon />}
          variant={SelectVariant.single}
          aria-label="Select Input"
          onToggle={this.onToggle}
          onSelect={this.onSelect}
          selections={selected}
          isExpanded={isExpanded}
          ariaLabelledBy={titleId}
          isDisabled={isDisabled}
          direction={direction}
        >
          {this.options.map((option, index) => (
            <SelectOption
              isDisabled={option.disabled}
              key={index}
              value={option.value}
              isPlaceholder={option.isPlaceholder}
            />
          ))}
        </Select>
        <Checkbox
          label="isDisabled"
          isChecked={this.state.isDisabled}
          onChange={this.toggleDisabled}
          aria-label="disabled checkbox"
          id="toggle-disabled"
          name="toggle-disabled"
        />
        <Checkbox
          label="Expands up"
          isChecked={direction === SelectDirection.up}
          onChange={this.toggleDirection}
          aria-label="direction checkbox"
          id="toggle-direction"
          name="toggle-direction"
        />
        <Checkbox
          label="Show icon"
          isChecked={isToggleIcon}
          onChange={this.setIcon}
          aria-label="show icon checkbox"
          id="toggle-icon"
          name="toggle-icon"
        />
      </div>
    );
  }
}

Warning: React does not recognize the createText prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase createtext instead. If you accidentally passed it from a parent component, remove it from the DOM element. in ul in SelectMenu in div in Select (at SingleSelectInput.js:83) in div (at SingleSelectInput.js:79) in SingleSelectInput (at App.js:204) ...

Warning: React does not recognize the noResultsFoundText prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase noresultsfoundtext instead. If you accidentally passed it from a parent component, remove it from the DOM element. in ul in SelectMenu in div in Select (at SingleSelectInput.js:83) in div (at SingleSelectInput.js:79) in SingleSelectInput (at App.js:204) ...

kzolti avatar Oct 26 '19 20:10 kzolti

Hi @kzolti we've seen this. I will bring this to the team and get back to you.

rachael-phillips avatar Oct 28 '19 14:10 rachael-phillips

Fixed as part of #3127

kmcfaul avatar Nov 04 '19 18:11 kmcfaul