Skip to content

Commit

Permalink
Revert "[TextField] fix running click event on disabled (mui#36892)"
Browse files Browse the repository at this point in the history
This reverts commit 9118505.
  • Loading branch information
mj12albert committed Aug 14, 2023
1 parent 9bec39b commit df79a98
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 29 deletions.
3 changes: 2 additions & 1 deletion packages/mui-material/src/InputBase/InputBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ const InputBase = React.forwardRef(function InputBase(inProps, ref) {
if (inputRef.current && event.currentTarget === event.target) {
inputRef.current.focus();
}
if (onClick && !fcs.disabled) {

if (onClick) {
onClick(event);
}
};
Expand Down
4 changes: 0 additions & 4 deletions packages/mui-material/src/TextField/TextField.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@ export interface BaseTextFieldProps
name?: string;
onBlur?: InputBaseProps['onBlur'];
onFocus?: StandardInputProps['onFocus'];
/**
* @ignore
*/
onClick?: InputBaseProps['onClick'];
/**
* The short hint displayed in the `input` before the user enters a value.
*/
Expand Down
6 changes: 0 additions & 6 deletions packages/mui-material/src/TextField/TextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const TextField = React.forwardRef(function TextField(inProps, ref) {
name,
onBlur,
onChange,
onClick,
onFocus,
placeholder,
required = false,
Expand Down Expand Up @@ -179,7 +178,6 @@ const TextField = React.forwardRef(function TextField(inProps, ref) {
onBlur={onBlur}
onChange={onChange}
onFocus={onFocus}
onClick={handleClick}
placeholder={placeholder}
inputProps={inputProps}
{...InputMore}
Expand Down Expand Up @@ -358,10 +356,6 @@ TextField.propTypes /* remove-proptypes */ = {
* You can pull out the new value by accessing `event.target.value` (string).
*/
onChange: PropTypes.func,
/**
* @ignore
*/
onClick: PropTypes.func,
/**
* @ignore
*/
Expand Down
19 changes: 1 addition & 18 deletions packages/mui-material/src/TextField/TextField.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { expect } from 'chai';
import { spy } from 'sinon';
import { createRenderer, describeConformance, fireEvent } from 'test/utils';
import { createRenderer, describeConformance } from 'test/utils';
import FormControl from '@mui/material/FormControl';
import { inputBaseClasses } from '@mui/material/InputBase';
import MenuItem from '@mui/material/MenuItem';
Expand Down Expand Up @@ -155,22 +154,6 @@ describe('<TextField />', () => {
});
});

describe('prop: disabled', () => {
it('should not run click event when disabled', () => {
const handleClick = spy();
const { getByRole } = render(<TextField disabled onClick={handleClick} />);
fireEvent.click(getByRole('textbox'));
expect(handleClick.callCount).to.equal(0);
});

it('should not run click event when disabled and when onClick prop is set through InputProps', () => {
const handleClick = spy();
const { getByRole } = render(<TextField disabled InputProps={{ onClick: handleClick }} />);
fireEvent.click(getByRole('textbox'));
expect(handleClick.callCount).to.equal(0);
});
});

describe('prop: select', () => {
it('can render a <select /> when `native`', () => {
const currencies = [
Expand Down

0 comments on commit df79a98

Please sign in to comment.