hsuanyi-chou / shadcn-ui-expansions

More components built on top of shadcn-ui.
https://shadcnui-expansions.typeart.cc/
MIT License
805 stars 37 forks source link

[bug]: Multiple Selector Focus on Form #127

Closed Sergionx closed 19 hours ago

Sergionx commented 1 month ago

Describe the bug

Using react-hookf-form, when and the Forms component from Shadcn I get this error if the Multiple Selector has an error and tries to focus it: TypeError: elm.focus is not a function

Affected component/components

Multiple Selector

How to reproduce

<FormField name={${subjectName}.prelations`} disabled={isSubjectElective} render={({ field:{...field} }) => (

            )}
          />`

Codesandbox/StackBlitz link

No response

Logs

chunk-JLCRCF3E.js?v=52a7f9b1:280 Uncaught (in promise) 
TypeError: elm.focus is not a function
    at Object.focus (chunk-JLCRCF3E.js?v=52a7f9b1:280:30)
    at _focusInput (chunk-JLCRCF3E.js?v=52a7f9b1:1430:11)
    at iterateFieldsByAction (chunk-JLCRCF3E.js?v=52a7f9b1:415:30)
    at _focusError (chunk-JLCRCF3E.js?v=52a7f9b1:1598:58)
    at chunk-JLCRCF3E.js?v=52a7f9b1:1646:7
focus   @   chunk-JLCRCF3E.js?v=52a7f9b1:280
_focusInput @   chunk-JLCRCF3E.js?v=52a7f9b1:1430
iterateFieldsByAction   @   chunk-JLCRCF3E.js?v=52a7f9b1:415
_focusError @   chunk-JLCRCF3E.js?v=52a7f9b1:1598
(anonymous) @   chunk-JLCRCF3E.js?v=52a7f9b1:1646
await in (anonymous)        
callCallback2   @   chunk-W6L2VRDA.js?v=52a7f9b1:3674
invokeGuardedCallbackDev    @   chunk-W6L2VRDA.js?v=52a7f9b1:3699
invokeGuardedCallback   @   chunk-W6L2VRDA.js?v=52a7f9b1:3733
invokeGuardedCallbackAndCatchFirstError @   chunk-W6L2VRDA.js?v=52a7f9b1:3736
executeDispatch @   chunk-W6L2VRDA.js?v=52a7f9b1:7014
processDispatchQueueItemsInOrder    @   chunk-W6L2VRDA.js?v=52a7f9b1:7034
processDispatchQueue    @   chunk-W6L2VRDA.js?v=52a7f9b1:7043
dispatchEventsForPlugins    @   chunk-W6L2VRDA.js?v=52a7f9b1:7051
(anonymous) @   chunk-W6L2VRDA.js?v=52a7f9b1:7174
batchedUpdates$1    @   chunk-W6L2VRDA.js?v=52a7f9b1:18913
batchedUpdates  @   chunk-W6L2VRDA.js?v=52a7f9b1:3579
dispatchEventForPluginEventSystem   @   chunk-W6L2VRDA.js?v=52a7f9b1:7173
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @   chunk-W6L2VRDA.js?v=52a7f9b1:5478
dispatchEvent   @   chunk-W6L2VRDA.js?v=52a7f9b1:5472
dispatchDiscreteEvent

System Info

No response

Before submitting

hsuanyi-chou commented 4 weeks ago

Please provide a minimal reproducible repo.

MohsinGhani commented 1 day ago

bro simply go the Multiple Selector component file that you created and then add a ? sign after every refs for example:

  1. Goto the file where you pasted the multi selector code.
  2. search using Command + F key and type focus() in the search bar.
  3. then you will find 3 inputRef.current?.focus(); statements .
  4. simply change them to inputRef?.current?.focus();

@hsuanyi-chou #140

hsuanyi-chou commented 19 hours ago

It's merged. Thank you very much!! @MohsinGhani