Repository navigation
fix(editor): restore focus after closing event popover - #8985
abhinavohri wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Hi @abhinavohri The ticket you linked has nothing to do with the changes you made. The ticket is about the calendar creation menu. |
|
Hi @SebastianKrupinski , my apologies I mixed up the issues. I followed the steps in the #4127, and the focus went back to the + button. So I think that issue is already fixed. If this change is still useful, should I open a new issue and update this PR to reference it, or would you prefer that I close the PR? |
|
I can't really tell if this PR is useful as I don't have a reference of an issue. What issue does this PR solve? |
When the simple editor is dismissed without creating an event, keyboard focus jumps to the top of the page. This PR returns focus to the element that was focused before the editor opened. |
|
What do you think? |
odzhychko
left a comment
There was a problem hiding this comment.
In general, it is good accessibility to return the focus after a modal is closed.
This is why NcModal uses the focus-trap library.
For the simple editor event popover I currently see three separate cases:
-
It is created by clicking the "+ Event" button.
In this case the focus should return to the button.
This should be automatically happen if we useNcModal.
Here it it worth investigation, why it does not happen.
I suspect we useNcModalnot as intended. -
User clicks on existing event, which opens preview and then user can click "Edit"
When use closes the editor, focus should return to the event where the user clicked.
Also here the focus trap mechanism ofNcModalshould work out-of-the box, but doesn't.
If it has to do with some way fullcalendar works,NcModal.setReturnFocusseems add custom focus return logic. -
User clicks (or drags) somewhere on the calendar which opens a dialog for a new event.
A sensible default would be to focus the day in the fullcalendar view.
NcModal.setReturnFocusseems to be the indented way to control this.
In summery: It would be nice to have focus returning implemented correctly eventually, but the current proposed solution seems not the correct one. Please check first, why the NcModal does not behave as expected and use NcModal.setReturnFocus in case we really have to intervene manually.
|
Hi @odzhychko , please correct me if I am missing something. The I tested the three cases, and my change restores focus only for the “+ Event” button. It does not restore focus for an existing event or a calendar selection. |
Oh, right. I just assume it uses Eventually we should refactor to
That's better then non of the cases ^^ Just for completeness, I now also though of:
@SebastianKrupinski @abhinavohri I'm fine with merging this without full refactoring, even if it works only for case 1. @abhinavohri In case you do not want to not handle the other cases or the refactoring in this PR, could you adapt the commit, PR title and description to reflect that? e.g. something like "restore focus to event creation button" @abhinavohri Could you add an e2e-test. Else this feature might be quickly lost when someone tries to refactor to @abhinavohri Out of curiosity: While looking at the code of the simple editor have you seen some reason that would block refactoring to to |
Assisted-by: Codex:gpt-5 Signed-off-by: Abhinav Ohri <abhinavohri13@gmail.com>
b3023c6 to
7109f3a
Compare
|
Hi @odzhychko , I have updated the PR title and commit and have also added the E2E test. Regarding refactoring EditSimple to NcModal, I can think of the following things to be blockers:
|
Summary
When the simple editor is dismissed without creating an event, keyboard focus jumps to the top of the page. This PR returns focus to the element that was focused before the editor opened.