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

DataGrid eliding does not respect unicode character integrity #456

Closed
krassowski opened this issue Nov 1, 2022 · 0 comments · Fixed by #578
Closed

DataGrid eliding does not respect unicode character integrity #456

krassowski opened this issue Nov 1, 2022 · 0 comments · Fixed by #578
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@krassowski
Copy link
Member

Description

For example https://www.compart.com/en/unicode/U+1F4E6

Screenshot from 2022-11-01 17-19-46

Reproduce

https://mybinder.org/v2/gh/jupyterlab/jupyterlab-plugin-playground/main?urlpath=lab with:

import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
import { MainAreaWidget } from '@jupyterlab/apputils';
import { DataGrid, DataModel, BasicKeyHandler, BasicMouseHandler, BasicSelectionModel } from '@lumino/datagrid';

class LargeDataModel extends DataModel {
  rowCount(region: DataModel.RowRegion): number {
    return region === 'body' ? 100 : 1;
  }

  columnCount(region: DataModel.ColumnRegion): number {
    return region === 'body' ? 10 : 1;
  }

  data(region: DataModel.CellRegion, row: number, column: number): any {
    if (region !== 'body') {
      return `${row}, ${column}`;
    }
    return '📦'.repeat(20);
  }
}

const extension: JupyterFrontEndPlugin<void> = {
  id: 'datagrid',
  autoStart: true,
  activate: (
    app: JupyterFrontEnd
  ) => {
    const model = new LargeDataModel();
    const content = new DataGrid();
  
    content.dataModel = model;
    // (handlers are not required for reproduction)
    content.keyHandler = new BasicKeyHandler();
    content.mouseHandler = new BasicMouseHandler();
    content.selectionModel = new BasicSelectionModel({
      dataModel: model
    });
    const widget = new MainAreaWidget({content});
    widget.id = 'datagrid-example';
    widget.title.label = 'Unicode Datagrid Example';
    app.shell.add(widget, 'main');
  },
};

export default extension;
  1. Rune the example provided above
  2. Try resizing one of the columns
  3. See unknown character show up

Expected behavior

Unicode-aware slice is used, see https://stackoverflow.com/a/62341816

@krassowski krassowski added bug Something isn't working status:Needs Triage good first issue Good for newcomers and removed status:Needs Triage labels Nov 1, 2022
nicojapas added a commit to nicojapas/lumino that referenced this issue Apr 26, 2023
krassowski pushed a commit to krassowski/lumino that referenced this issue May 11, 2023
…pyterlab#578)

* Invalid unicode characters removed (jupyterlab#456)

* Using arrays

* Simplified structure

* Prettified
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant