Skip to content

Commit

Permalink
rename pointer to mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Dec 14, 2019
1 parent 29af7a2 commit ca14ef7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/pages/api/autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
| <span class="prop-name">autoComplete</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the portion of the selected suggestion that has not been typed by the user, known as the completion string, appears inline after the input cursor in the textbox. The inline completion string is visually highlighted and has a selected state. |
| <span class="prop-name">autoHighlight</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the first option is automatically highlighted. |
| <span class="prop-name">autoSelect</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, the selected option becomes the value of the input when the Autocomplete loses focus unless the user chooses a different option or changes the character string in the input. |
| <span class="prop-name">blurOnSelect</span> | <span class="prop-type">'pointer'<br>&#124;&nbsp;'touch'<br>&#124;&nbsp;bool</span> | <span class="prop-default">false</span> | Control if the input should be blurred when an option is selected:<br>- `false` the input is not blurred. - `true` the input is always blurred. - `touch` the input is blurred only on touch devices. - `pointer` the input is blurred only on pointing devices. |
| <span class="prop-name">blurOnSelect</span> | <span class="prop-type">'mouse'<br>&#124;&nbsp;'touch'<br>&#124;&nbsp;bool</span> | <span class="prop-default">false</span> | Control if the input should be blurred when an option is selected:<br>- `false` the input is not blurred. - `true` the input is always blurred. - `touch` the input is blurred after a touch event. - `mouse` the input is blurred after a mouse event. |
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| <span class="prop-name">clearOnEscape</span> | <span class="prop-type">bool</span> | <span class="prop-default">false</span> | If `true`, clear all values when the user presses escape and the popup is closed. |
| <span class="prop-name">clearText</span> | <span class="prop-type">string</span> | <span class="prop-default">'Clear'</span> | Override the default text for the *clear* icon button.<br>For localization purposes, you can use the provided [translations](/guides/localization/). |
Expand Down
6 changes: 3 additions & 3 deletions packages/material-ui-lab/src/Autocomplete/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ Autocomplete.propTypes = {
*
* - `false` the input is not blurred.
* - `true` the input is always blurred.
* - `touch` the input is blurred only on touch devices.
* - `pointer` the input is blurred only on pointing devices.
* - `touch` the input is blurred after a touch event.
* - `mouse` the input is blurred after a mouse event.
*/
blurOnSelect: PropTypes.oneOfType([PropTypes.oneOf(['pointer', 'touch']), PropTypes.bool]),
blurOnSelect: PropTypes.oneOfType([PropTypes.oneOf(['mouse', 'touch']), PropTypes.bool]),
/**
* Override or extend the styles applied to the component.
* See [CSS API](#css) below for more details.
Expand Down
38 changes: 19 additions & 19 deletions packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ describe('<Autocomplete />', () => {
fireEvent.click(input);

const listbox = getByRole('listbox');
const firstItem = listbox.querySelector('li');
fireEvent.click(firstItem);
const firstOption = listbox.querySelector('li');
fireEvent.click(firstOption);

expect(handleChange.args[0][1]).to.equal('one');
});
Expand Down Expand Up @@ -792,17 +792,17 @@ describe('<Autocomplete />', () => {
/>,
);
const textbox = getByRole('textbox');
let firstItem = getByRole('option');
let firstOption = getByRole('option');
expect(textbox).to.have.focus;
fireEvent.click(firstItem);
fireEvent.click(firstOption);
expect(textbox).to.not.have.focus;

const opener = queryByTitle('Open');
fireEvent.click(opener);
expect(textbox).to.have.focus;
firstItem = getByRole('option');
fireEvent.touchStart(firstItem);
fireEvent.click(firstItem);
firstOption = getByRole('option');
fireEvent.touchStart(firstOption);
fireEvent.click(firstOption);
expect(textbox).to.not.have.focus;
});

Expand All @@ -817,38 +817,38 @@ describe('<Autocomplete />', () => {
/>,
);
const textbox = getByRole('textbox');
let firstItem = getByRole('option');
fireEvent.click(firstItem);
let firstOption = getByRole('option');
fireEvent.click(firstOption);
expect(textbox).to.have.focus;

const opener = queryByTitle('Open');
fireEvent.click(opener);
firstItem = getByRole('option');
fireEvent.touchStart(firstItem);
fireEvent.click(firstItem);
firstOption = getByRole('option');
fireEvent.touchStart(firstOption);
fireEvent.click(firstOption);
expect(textbox).to.not.have.focus;
});

it('[blurOnSelect="pointer"] should only blur the input when an option is clicked', () => {
it('[blurOnSelect="mouse"] should only blur the input when an option is clicked', () => {
const options = [{ name: 'foo' }];
const { getByRole, queryByTitle } = render(
<Autocomplete
options={options}
getOptionLabel={option => option.name}
renderInput={params => <TextField {...params} autoFocus />}
blurOnSelect="pointer"
blurOnSelect="mouse"
/>,
);
const textbox = getByRole('textbox');
let firstItem = getByRole('option');
fireEvent.touchStart(firstItem);
fireEvent.click(firstItem);
let firstOption = getByRole('option');
fireEvent.touchStart(firstOption);
fireEvent.click(firstOption);
expect(textbox).to.have.focus;

const opener = queryByTitle('Open');
fireEvent.click(opener);
firstItem = getByRole('option');
fireEvent.click(firstItem);
firstOption = getByRole('option');
fireEvent.click(firstOption);
expect(textbox).to.not.have.focus;
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export interface UseAutocompleteProps {
*
* - `false` the input is not blurred.
* - `true` the input is always blurred.
* - `touch` the input is blurred only on touch devices.
* - `pointer` the input is blurred only on pointing devices.
* - `touch` the input is blurred after a touch event.
* - `mouse` the input is blurred after a mouse event.
*/
blurOnSelect?: 'touch' | 'pointer' | true | false;
blurOnSelect?: 'touch' | 'mouse' | true | false;
/**
* If `true`, clear all values when the user presses escape and the popup is closed.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ export default function useAutocomplete(props) {
if (
blurOnSelect === true ||
(blurOnSelect === 'touch' && isTouch.current) ||
(blurOnSelect === 'pointer' && !isTouch.current)
(blurOnSelect === 'mouse' && !isTouch.current)
) {
inputRef.current.blur();
}
Expand Down

0 comments on commit ca14ef7

Please sign in to comment.