bosskmk / pluto_grid

PlutoGrid is a dataGrid for flutter that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS.
https://pluto.weblaze.dev
MIT License
637 stars 291 forks source link

[Bug] SelectableText within PlutoGrid not copying content on Flutter Web #928

Closed motucraft closed 9 months ago

motucraft commented 10 months ago

Steps to reproduce the bug

  1. Implement a PlutoGrid with a column that uses a SelectableText renderer.
  2. Run the Flutter web application.
  3. Try to select and copy the content of the cell using the browser's standard copy shortcut (e.g., Command + C for MacOS or Ctrl + C for Windows/Linux).

Expected results

After selecting the content of the cell, users should be able to copy the content to the clipboard using the browser's standard copy shortcut.

Actual results

The content of the SelectableText within the cell cannot be copied to the clipboard using standard copy shortcuts.

Code sample

import 'package:flutter/material.dart';
import 'package:pluto_grid/pluto_grid.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Sample Grid',
      home: SampleGrid(),
    );
  }
}

class SampleGrid extends StatelessWidget {
  const SampleGrid({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: PlutoGrid(
        columns: columns,
        rows: rows,
      ),
    );
  }
}

List<PlutoColumn> columns = [
  PlutoColumn(
    title: 'text column1',
    field: 'text_field1',
    type: PlutoColumnType.text(),
  ),
  PlutoColumn(
      title: 'text column2',
      field: 'text_field2',
      type: PlutoColumnType.text(),
      enableEditingMode: false,
      renderer: (rendererContext) {
        // FIXME
        return const SelectableText('I want to copy to the clipboard.');
      }),
];

List<PlutoRow> rows = [
  PlutoRow(
    cells: {
      'text_field1': PlutoCell(value: 'Text cell value1'),
      'text_field2': PlutoCell(value: 'Text cell value2'),
    },
  ),
];

Execution Environment

Flutter version

Flutter version is 3.13.1

PlutoGrid version

PlutoGrid version is 7.0.2

OS

macOS Ventura 13.5.1

github-actions[bot] commented 9 months ago

This issue is stale because it has been open for 30 days with no activity.

motucraft commented 9 months ago

Situation has not changed.

ryanlalchand commented 9 months ago

@motucraft I am able to select a cell and copy without a special renderer for the cell value, just using the PlutoColumnType and setting the value. I have the following configuration, hope this helps!

PlutoGrid( mode: PlutoGridMode.select, onLoaded: (event) => { stateManager = event.stateManager, stateManager.setSelectingMode(PlutoGridSelectingMode.row), },)

motucraft commented 9 months ago

@ryanlalchand Thank you for your insight, it is much appreciated.