Skip to content

Commit

Permalink
Fix name of story and reset inputValueChangedRef when uncontrolled
Browse files Browse the repository at this point in the history
  • Loading branch information
dlacaille committed Apr 14, 2021
1 parent 2207cb4 commit 3112a81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/combobox/examples/simulated-change.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { useCityMatch } from "./utils";
import "@reach/combobox/styles.css";

let name = "Controlled";
let name = "Simulated Change";

function Example() {
let [term, setTerm] = React.useState("Detroit");
Expand All @@ -35,8 +35,8 @@ function Example() {
<h2>Clientside Search</h2>
<p>
This example tests that changes to the controlled value of Combobox
don't trigger it to open unless we are actually typing. The initial
value and programmatically set value here shouldn't open the Popover.
don't expand it unless we are actually typing. The initial value and
programmatically set value here shouldn't open the Popover.
</p>
<p>Selection: {selection}</p>
<p>Term: {term}</p>
Expand Down
6 changes: 3 additions & 3 deletions packages/combobox/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,10 @@ export const ComboboxInput = React.forwardRef(function ComboboxInput(
(controlledValue!.trim() === "" ? (value || "").trim() !== "" : true)
) {
handleValueChange(controlledValue!);
// After we handled the changed value, we need to make sure the next
// controlled change won't trigger a CHANGE event. (instead of a SIMULATED_CHANGE)
inputValueChangedRef.current = false;
}
// After we handled the changed value, we need to make sure the next
// controlled change won't trigger a CHANGE event. (instead of a SIMULATED_CHANGE)
inputValueChangedRef.current = false;
}, [controlledValue, handleValueChange, isControlled, value]);

// [*]... and when controlled, we don't trigger handleValueChange as the
Expand Down

0 comments on commit 3112a81

Please sign in to comment.