MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit

Refocus after Dialog close triggers Tab change

Abierto
#1,121 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

enhancement evaluation required
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

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. 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

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.