Skip to content

Commit 8da427b

Browse files
committed
v0.3.3 allow confirm button trigger submit flow
1 parent 0f123b5 commit 8da427b

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-bootstrap-easy-dialog",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"description": "React Bootstrap Dialog made easy",
55
"keywords": [
66
"react-bootstrap",

src/Dialog.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export function DialogUI({
167167

168168
const [inputValue, setInputValue] = useState("");
169169
const inputRef = useRef();
170+
const submitButtonRef = useRef();
170171

171172
// only set input value to default value when it shows up
172173
useEffect(() => {
@@ -196,7 +197,11 @@ export function DialogUI({
196197
}
197198

198199
function handleConfirm() {
199-
onConfirm(inputValue);
200+
if (submitButtonRef.current) {
201+
submitButtonRef.current.click();
202+
} else {
203+
onConfirm();
204+
}
200205
}
201206

202207
function handleHide() {
@@ -233,14 +238,15 @@ export function DialogUI({
233238
)}
234239
{input && (
235240
<Form onSubmit={handleSubmit}>
236-
{input && (
237-
<Form.Control
238-
{...otherInputProps}
239-
value={inputValue}
240-
onChange={handleInputValueChange}
241-
{...{ [refKey]: inputRef }}
242-
/>
243-
)}
241+
<Form.Control
242+
{...otherInputProps}
243+
value={inputValue}
244+
onChange={handleInputValueChange}
245+
{...{ [refKey]: inputRef }}
246+
/>
247+
<Button type="submit" hidden ref={submitButtonRef}>
248+
Submit
249+
</Button>
244250
</Form>
245251
)}
246252
</Modal.Body>

0 commit comments

Comments
 (0)