mirror of
https://github.com/discourse/discourse.git
synced 2025-02-05 19:11:13 +00:00
DEV: Add autofocus
option to d-menu (#26829)
(to be used by the glimmer replacement of topic-entrance component)
This commit is contained in:
parent
3a69824ffb
commit
b39736a167
@ -242,4 +242,17 @@ module("Integration | Component | FloatKit | d-menu", function (hooks) {
|
||||
|
||||
assert.dom(".fk-d-menu").doesNotExist();
|
||||
});
|
||||
|
||||
test("@autofocus", async function (assert) {
|
||||
await render(hbs`
|
||||
<DMenu @inline={{true}} @autofocus={{true}}>
|
||||
<:content>
|
||||
<DButton class="my-button" />
|
||||
</:content>
|
||||
</DMenu>
|
||||
`);
|
||||
await open();
|
||||
|
||||
assert.dom(document.activeElement).hasClass("my-button");
|
||||
});
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ export default class DFloatBody extends Component {
|
||||
aria-expanded={{if @instance.expanded "true" "false"}}
|
||||
role={{@role}}
|
||||
{{FloatKitApplyFloatingUi this.trigger this.options @instance}}
|
||||
{{(if @trapTab (modifier TrapTab autofocus=false))}}
|
||||
{{(if @trapTab (modifier TrapTab autofocus=this.options.autofocus))}}
|
||||
{{(if
|
||||
this.supportsCloseOnClickOutside
|
||||
(modifier FloatKitCloseOnClickOutside this.trigger @instance.close)
|
||||
|
@ -46,6 +46,7 @@ export const MENU = {
|
||||
options: {
|
||||
animated: true,
|
||||
arrow: false,
|
||||
autofocus: false,
|
||||
beforeTrigger: null,
|
||||
closeOnEscape: true,
|
||||
closeOnClickOutside: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user