base-ui icon indicating copy to clipboard operation
base-ui copied to clipboard

[Dialog] Configure initial focus

Open michaldudak opened this issue 1 year ago • 1 comments

Added the initialFocus prop to control what element is focused after the Dialog is open. By default it focuses the first element, unless the Dialog was opened by touch interaction - in that case the Dialog itself is focused.

Part of #714

michaldudak avatar Oct 10 '24 08:10 michaldudak

Netlify deploy preview

https://deploy-preview-732--base-ui.netlify.app/

Generated by :no_entry_sign: dangerJS against 34050160ee8537618d0bfcd0d70576efc515cb84

mui-bot avatar Oct 10 '24 08:10 mui-bot

@vladmoroz I'll address the bug in a separate PR.

An empty string is a valid value of PointerEvent's pointerType field, so I included it here as well.

As for naming, yeah, I suppose we can think of something better. triggerType?

michaldudak avatar Oct 23 '24 10:10 michaldudak

@michaldudak what does the empty string mean?

What about "eventType"? "triggerType" sounds like it has to do with the trigger part

vladmoroz avatar Oct 23 '24 10:10 vladmoroz

An empty string is an unknown pointer type (see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType#value).

It's not really the type of the event (as this is PointerEvent or MouseEvent), but the user's input device that caused the event to fire (= triggered it).

michaldudak avatar Oct 23 '24 10:10 michaldudak

An empty string is an unknown pointer type (see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType#value).

Eww 😬

If the browser supports pointer device types other than those listed above, the value should be vendor-prefixed to avoid conflicting names for different types of devices.

Do we return an empty string in this case or do we pass through the original type?

vladmoroz avatar Oct 23 '24 10:10 vladmoroz

Do we return an empty string in this case or do we pass through the original type?

We pass through whatever there is originally.

michaldudak avatar Oct 29 '24 13:10 michaldudak