Comments (5)
So, I'll try to be as structured as possible(all is personal opinion):
- About the concerns of this issue:
1.1 About not allowing focus to leave the dialog, I don't agree that it should be provided by the dialog. A complete cross-platform tab trap implementation seems quite the challenge. If there is some library that does this then wrapping it in custom attribute seems way more logical.
1.2 Capturing and restoring a focused element seems to be one of the appropriate things to be done in aRenderer
, and it would be nice if it can be done as a reusable logic that other renderers can utilize. Also it must be taken into consideration any possible implications of having multiple open dialogs. - Current weak points of the dialog:
2.1 TheRederer
concept does not seem well defined, it seems that it's only concern should be attaching/detaching, but it is used for other purposes as well, like adding common dialog elements(backdrop, etc.), common behaviors(keyboard, mouse). This behaviors are internal impls of the default renderer, no other renderer can just plug them in(I don't mean inheritance). Also there are some settings inDialogSettings
concerning them, so does this make them mandatory for every renderer? If it is, does adding a new setting(about locating a fallback element to focus) make other custom renderers "broken"?
2.2 No official way to pass custom settings - be it to the view model,Renderer
, etc.
2.3 Lack of proper separation - all out-of-the-box custom elements/attributes, renderers, etc., should be in separate package/s. Currently I see this as a burden for the build setups.
from dialog.
@timfish @bigopon Any thoughts?
from dialog.
Maybe we can have an interface for this, say IFocusManager
:
interface IFocusManager {
// return element to be focused when this dialog is closed
// return null means don't focus anything?
onDialogOpen(lastActiveElement: HTMLElement): HTMLElement;
// only invoked when onDialogOpen returns an element?
// return null means don't focus anything?
onDialogClosed(toBeFocusedElement: HTMLElement): HTMLElement;
}
Basically when dealing with form, focus strategy may need to be more than just simple last blurred first focused.
from dialog.
@bigopon I went for a simpler interface. If a developer wants to restore focus to a different element they can simply override the restoreFocus
setting and track the element themselves. The restoreFocus
setting can be overriden in plugin settings or on a case-by-case basis by overriding at each DialogService.open()
call.
@StrahilKazlachev I went for a simple addition to both renderers. While I agree that the code could do with some refactoring, I think it's out of scope for this bug.
from dialog.
Fixed in #378
from dialog.
Related Issues (20)
- Dialog VM hooks for keyboard (Enter/Escape) HOT 7
- Add class reference support for .viewModel HOT 4
- Plugin setting configurations not working HOT 1
- Error when building HOT 1
- AttachFocus is not the default export
- Bug: Lazy loading components causes unnecessary webpack chunks HOT 14
- Dialog does not open when webpack bundle is built in production mode HOT 7
- Remove .rollupcache folder from npm package
- Cannot find name 'AddEventListenerOptions'. HOT 7
- Global callbacks / events every time a dialog opens / closes HOT 8
- Typings fail to install HOT 1
- typings.json does not define dependency versions HOT 2
- DialogCloseError is not exposed in typings HOT 2
- Add whenConfirmed alongside whenClosed HOT 1
- Doesn't load template page in IE11 HOT 12
- null reference error on closing dialog
- Support typing the model with a generic type argument on the open method HOT 2
- dialog forces mulptiple chunks in webpack prod build HOT 1
- 404 on typings install for Aurelia metadata HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dialog.