question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[terra-form-select] Invalid onBlur events triggered when selecting an option

See original GitHub issue

Bug Report

Description

The Select component is triggering inappropriate onBlur events when selecting options.

Switching the variant produces different onBlur results.

Default Variant:

A default variant will fire onBlur every time an option is selected. (Mobile and Desktop)

Multiple/Search/Tag/Combobox:

The onBlur fires when the first option is selected and the dropdown menu closes. (Mobile)

Example Code:

import React, { useState } from 'react';
import Select from 'terra-form-select';

const Example = () => {
  const [value, setValue] = useState(['blue']);
  const [count, setCount] = useState(0);

  return (
    <div>
      <p>{`Blur Count: ${count}`}</p>
      <Select variant="multiple" onBlur={() => { setCount(count + 1); }} value={value} onChange={setValue}>
        <Select.Option value="blue" display="Blue" />
        <Select.Option value="green" display="Green" />
        <Select.Option value="purple" display="Purple" />
        <Select.Option value="red" display="Red" />
        <Select.Option value="violet" display="Violet" />
      </Select>
    </div>
  );
};

export default Example;

Steps to Reproduce

  1. Create a demo page using the code snippet above.
  2. Click on the arrow button of the Select to open the dropdown.
  3. Select an option.
  4. Observe the onBlur event count.
  5. Repeat steps 2-4 with each variant and observe they behave differently.

Note: The behavior is different when the dropdown is opened via clicking the arrow button vs clicking into the text/selection region.

Note: The behavior is different on desktop and mobile. Each variant should be testing on both desktop and mobile.

Additional Notes

The mobile workflows were tested on mobile iOS Safari using an iPhone X.

Expected Behavior

The onBlur event should only fire when focus navigates away from the Select. For the tag/multiple variants the dropdown menu should not close when selecting the first option.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
StephenEssercommented, Feb 19, 2020

@nramamurth I’ve updated the reproduction steps to include directions for clicking the arrow button. I wasn’t aware clicking the arrow button behaved differently until I double checked after @pranav300’s comment. Both workflows should be checked while working on this issue for both mobile and desktop.

0reactions
StephenEssercommented, Mar 11, 2020

@pranav300 @saket2403 (Issue assignees). This issue came up during office hours, are there any updates? Are both or either of you working on this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-hook-form: Validation not working when using onBlur ...
In your code, the form mode is onBlur . it means the validation is triggered on blur event (unfocus the input). When you...
Read more >
onblur/onfocus events fired after selecting item from dropdown
Intuitively, the onfocus event should fire only when the trigger is entered ... is unfocused for an external focus (not for dropdown select)....
Read more >
onblur Event - W3Schools
The onblur event occurs when an element loses focus. ... The onblur event is often used with form validation (when the user leaves...
Read more >
react hook form onblur not working - You.com | The AI Search ...
In your code, the form mode is onBlur . it means the validation is triggered on blur event (unfocus the input). When you...
Read more >
Element: blur event - Web APIs | MDN
The blur event fires when an element has lost focus. The event does not bubble, but the related focusout event that follows does...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found