react-data-grid icon indicating copy to clipboard operation
react-data-grid copied to clipboard

Chrome mobile emulator: can't go to edit cell mode

Open d9k opened this issue 2 years ago • 6 comments

Can't go to cell edit mode by touch events emulated by Chrome DevTools (Toggle Device Toolbar)

Double touch does nothing. Cell can be edited with F2, but physical keyboard is unavailable on most mobile devices.

https://adazzle.github.io/react-data-grid/#/all-features

d9k avatar Dec 18 '23 02:12 d9k

My work around is to use Context Menu which can be triggered via "Tap Hold" on emulator and right click on Desktop

image

holospice18 avatar Dec 22 '23 02:12 holospice18

@holospice18, can you share the code?

d9k avatar Dec 25 '23 21:12 d9k

I used the example from https://adazzle.github.io/react-data-grid/#/context-menu Source: https://github.com/adazzle/react-data-grid/blob/main/website/demos/ContextMenu.tsx

holospice18 avatar Dec 27 '23 00:12 holospice18

@holospice18, how do you switch cell to edit mode programmatically?

d9k avatar Jan 22 '24 19:01 d9k

First, I exposed 'SelectCell' prop on 'onCellContextMenu'

onCellContextMenu = {({ row, column, selectCell }, event) => {...}


-----

Then pass it as props

setContextMenu(
	contextMenu === null
	? {
		row: row,
		rowIdx:  rows.indexOf(row),
		column:  column,
		selectCell: selectCell,
		}
	: 
	// repeated contextmenu when it is already open closes it with Chrome 84 on Ubuntu
	// Other native context menus might behave different.
	// With this behavior we prevent contextmenu from the backdrop to re-locale existing context menus.
	
	null,
);

-----

Then on menuClick 'props' = contextMenu

const handleMenuEdit = async (props) => {
	let rowIdx = props.rowIdx;
	props.selectCell({ rowIdx, idx: props.column.idx });        
};

-----

The 'onCellContextMenu' will look something like this:

<Grid
...
onCellContextMenu = {({ row, column, selectCell }, event) => 
	{
		
	event.preventGridDefault();
	// Do not show the default context menu
	event.preventDefault();

	setContextMenu(
		contextMenu === null
		? {
			row: row,
			rowIdx:  rowIdx,
			column:  column,
			selectCell: selectCell,
			}
		: 
		// repeated contextmenu when it is already open closes it with Chrome 84 on Ubuntu
		// Other native context menus might behave different.
		// With this behavior we prevent contextmenu from the backdrop to re-locale existing context menus.
		
		null,
	);
		
		
	}
}
/>

holospice18 avatar Feb 20 '24 08:02 holospice18

Tried editing through both the dev tools and through an android mobile device - the inline editing doesn't work.

But a context menu isn't desired in my case - just triggering the edit mode (renderEditCell) of the cell. It can only work clunkily with a workaround using onCellContextMenu.

suuf avatar Jun 06 '25 08:06 suuf