Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
d9k opened this issue Dec 18, 2023 · 5 comments
Open

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

d9k opened this issue Dec 18, 2023 · 5 comments
Labels

Comments

@d9k
Copy link

d9k commented Dec 18, 2023

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 d9k added the Bug label Dec 18, 2023
@holospice18
Copy link

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

image

@d9k
Copy link
Author

d9k commented Dec 25, 2023

@holospice18, can you share the code?

@holospice18
Copy link

@d9k
Copy link
Author

d9k commented Jan 22, 2024

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

@holospice18
Copy link

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,
	);
		
		
	}
}
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants