-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ElementDocument::FocusFirstTabElement #40
Comments
It seems good, but what do you think about an autofocus attribute so it's easier to customize the element to focus? |
Yeah, I like the autofocus idea. The code should be able to handle multiple autofocus elements too and always pick the first one. Another thing to note is that the focus should not change when the document is hidden away and shown again. The property alone isn't going to allow you to reset the focus though. |
Alright, that should be doable. So only set it during document load for example? |
I think it should be postponed until before the first Show() call with the focus flag set, since autofocus is dependent on visibility state of the elements and a whole lot can happen between load and show events... |
Hm, maybe a FocusElement flag during document show to control it? |
That was one of the alternative suggestions in my original post :) |
Right :P |
Let me know how it works for you. :) |
What I don't like about this approach is that doing or
on an already displayed document resets the modal flag so I need to keep track of it myself, which is quite inconvenient.
|
This is how it worked before, right? What behavior do you propose? |
Maybe like this? |
Well, the original proposal was to add a new method called FocusOnFirstTabElement(), which would only do what the name suggests :)
Is it really necessary to change the modal flag on visibility status change? On a related note, in ComputedValues.h:
Wouldn't it be better/make more sense to default this to Visibility::Hidden? Also, in ElementDocument::ProcessHeader:
doesn't set the linked computed value to corresponding value. I know this is expected behavior but it does cause certain problems with iframes: querying the parent document's visibility status on initialization always returns true. |
Okay, how about a separate FocusDocument(FocusFlag) function which does not modify visibility or modal status? Leave Show() like it was previously. The Focus() function is an element function and would only focus the document element itself. We could override this instead, but I think it would be a bit weird if Element::Focus has different behavior than ElementDocument::Focus?
I think it would be very unexpected in the case of calling
Oh no this would be very strange if all elements started out hidden. The default values must correspond to the default property value.
Yeah, it could make sense to run UpdateProperties after loading the header, which should solve this issue. |
Maybe like this: /**
ModalFlag used for controlling the modal state of the document.
None: Remove modal state.
Modal: Set modal state, other documents cannot receive focus.
Previous: Modal state unchanged.
FocusFlag used for displaying the document.
None: No focus.
Auto: Focus the first tab element with the 'autofocus' attribute or else the document.
Previous: Focus the previously focused element in the document.
Document: Focus the document.
*/
enum class ModalFlag { None, Modal, Previous };
enum class FocusFlag { None, Auto, Previous, Document };
ElementDocument::Show(ModalFlag modal_flag = ModalFlag::None, FocusFlag focus_flag = FocusFlag::Auto); |
I believe Current would be a more fitting term here than Previous |
Hm, I don't really like Previous either, but Current is also very strange, especially when showing the document. |
Keep or NoChange then maybe? :P |
Alright, Keep it is: 07805b7 :) |
Are you okay with the solution, can we close this? |
Yup, I'm fine with it, thanks! |
We use this function to focus on the first "tabbable" element when the document is displayed for the first time, if possible. Make sense for modal dialogs, input forms and such.
Please consider adding this function to the public API or maybe, as an alternative, a new Focus flag with similar functionality.
The text was updated successfully, but these errors were encountered: