Skip to content

Commit

Permalink
Merge pull request ramp4-pcar4#2488 from IshavSohal/issue-2375
Browse files Browse the repository at this point in the history
Add tooltip to grid for keyboard users (ramp4-pcar4#2488)
  • Loading branch information
szczz authored Dec 9, 2024
2 parents 30b758f + 9ac2481 commit 89389c8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/fixtures/grid/lang/lang.csv
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ grid.filters.date.min,Min Date,1,Date min,1
grid.filters.label.info,{range} of {total} entries shown,1,{range} de {total} saisies affichées,1
grid.filters.label.filtered,(filtered from {max} total entries),1,(filtré à partir d'un total de {max} saisies),1
grid.filters.label.extent,Filter by extent,1,Filtrer par étendue,1
grid.cells.controls,Use arrow keys to navigate grid cells. Press Tab to proceed,1,Utilisez les flèches pour parcourir les cellules de la grille. Appuyez sur Tab pour continuer,0
grid.cells.zoom,Zoom to feature,1,Zoom à l'élément,1
grid.cells.zoom.zooming,Zooming...,1,Zoom en cours...,1
grid.cells.zoom.error,Zoom failed,1,Échec du zoom,1
Expand Down
63 changes: 46 additions & 17 deletions src/fixtures/grid/table-component.vue
Original file line number Diff line number Diff line change
Expand Up @@ -330,25 +330,36 @@
</div>
</div>

<!-- main grid component -->
<ag-grid-vue
<div
:content="t('grid.cells.controls')"
v-tippy="{
placement: 'top',
trigger: 'manual'
}"
class="w-full h-full flex flex-col"
v-if="showGrid"
v-show="!isLoadingGrid && !isErrorGrid"
class="ag-theme-material flex-grow"
enableCellTextSelection="true"
accentedSort="true"
:localeText="locale === 'en' ? AG_GRID_LOCALE_EN : AG_GRID_LOCALE_FR"
:gridOptions="agGridOptions"
:columnDefs="columnDefs"
:rowData="rowData"
:components="frameworkComponents"
@grid-ready="onGridReady"
@keydown="stopArrowKeyProp"
@firstDataRendered="gridRendered"
@cell-key-press="onCellKeyPress"
:doesExternalFilterPass="doesExternalFilterPass"
:isExternalFilterPresent="isExternalFilterPresent"
/>
ref="gridContainer"
tabIndex="-1"
>
<!-- main grid component -->
<ag-grid-vue
class="ag-theme-material flex-grow"
enableCellTextSelection="true"
accentedSort="true"
:localeText="locale === 'en' ? AG_GRID_LOCALE_EN : AG_GRID_LOCALE_FR"
:gridOptions="agGridOptions"
:columnDefs="columnDefs"
:rowData="rowData"
:components="frameworkComponents"
@grid-ready="onGridReady"
@keydown="stopArrowKeyProp"
@firstDataRendered="gridRendered"
@cell-key-press="onCellKeyPress"
:doesExternalFilterPass="doesExternalFilterPass"
:isExternalFilterPresent="isExternalFilterPresent"
/>
</div>
</div>
</template>

Expand All @@ -361,7 +372,9 @@ import {
nextTick,
onBeforeMount,
onBeforeUnmount,
onMounted,
ref,
useTemplateRef,
watch
} from 'vue';
Expand Down Expand Up @@ -493,6 +506,7 @@ const panelStore = usePanelStore();
const mobileView = computed(() => panelStore.mobileView);
const pinned = ref<Boolean>(!mobileView.value);
const el = ref<HTMLElement>();
const gridContainer = useTemplateRef('gridContainer');
const { t, locale } = useI18n();
const forceUpdate = () => getCurrentInstance()?.proxy?.$forceUpdate();
Expand Down Expand Up @@ -1582,6 +1596,15 @@ const setUpColumns = () => {
});
};
onMounted(() => {
gridContainer.value?.addEventListener('focus', () => {
(gridContainer.value as any)._tippy.show();
});
gridContainer.value?.addEventListener('blur', () => {
(gridContainer.value as any)._tippy.hide();
});
});
onBeforeMount(() => {
config.value = gridStore.grids[props.gridId];
Expand Down Expand Up @@ -1672,6 +1695,12 @@ onBeforeUnmount(() => {
watchers.value.forEach(unwatch => unwatch());
gridAccessibilityManager.value?.removeAccessibilityListeners();
gridAccessibilityManager.value?.removeScrollListeners();
gridContainer.value?.removeEventListener('focus', () => {
(gridContainer.value as any)._tippy.show();
});
gridContainer.value?.removeEventListener('blur', () => {
(gridContainer.value as any)._tippy.hide();
});
});
</script>

Expand Down

0 comments on commit 89389c8

Please sign in to comment.