MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit
Refocus after Dialog close triggers Tab change
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 16.3k
- Forks
- 3.5k
- Merge medio
- 1 d 22 h
- PR fusionados (30 d)
- 8
Descripción
The DialogHost tries to "re-focus" the item previously selected. This is the code for it:
https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/5533b50a6cff78cb75fbb52e16f7c9e06c62446c/MaterialDesignThemes.Wpf/DialogHost.cs#L268
This is very problematic, when the previous control was a TabItem, because Focus()ing a TabItem actually activates the respective tab.
Here is a very simple reproduction:
- Have a TabControl within a DialogHost
- Focus a given TabItem (i.e. by clicking on an already active Tab)
- In the SelectionChanging Event of the TabControl Show the Dialog (i.e. "Loading data ...")
- Click another Tab
The following happens:
- DialogHost remembers, that the first tab is currently focused
- The click on the second Tab activates this Tab
- Dialog is shown and closed again, after data is loaded
- Dialog calls Focus() on first tab
=> First tab will be selected again
I just created the issue as I'm not sure, what the best solution for this. My current feeling tells me to just check for if(!(dialogHost._restoreFocusDialogClose is TabItem), but there might be other elements, where a re-focus is not desired?
I'd be happy to provide a PR after we agree on a solution.
Also - for now, I'd welcome any idea for a good workaround I could place into the application to make it work for now.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en DialogHost.cs alrededor de la línea 268 y reproduce la interacción con un TabControl, un TabItem y un controlador SelectionChanging que abre un diálogo. Investiga si la restauración del foco en el elemento seleccionado anteriormente debe omitirse o gestionarse de otra manera para los elementos de pestaña, y verifica que cerrar el diálogo deje activa la pestaña recién seleccionada.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp
- Área
- desktop
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100