ant-design/ant-design

Input doesn't respond to w3c standard interaction for element clear

Open

#37,439 opened on 2022年9月7日

GitHub で見る
 (5 comments) (0 reactions) (0 assignees)TypeScript (98,031 stars) (54,612 forks)batch import
Inactivehelp wanted

説明

Reproduction link

https://codesandbox.io/s/antd-reproduction-template-forked-n98f62

Steps to reproduce

As this needs a browser test using webdriver, I have set up a Laravel Dusk repo. Dusk uses PHP Webdriver initially created by facebook. https://github.com/php-webdriver/php-webdriver.

The below test code could be implemented in any language that uses the w3c webdriver standard to the same result.

The browser test will test the site at https://n98f62.csb.app/

The following steps should reproduce the issue, although the php/composer install can be different depending on your system.

  • git clone https://github.com/patrickomeara/antd-w3c-driver-clear && cd antd-w3c-driver-clear
  • brew install php composer
  • composer install
  • php artisan dusk:chrome-driver
  • php artisan dusk

The final command should fail and create a screenshot in ./tests/Browser/screenshots (embedded below)

What is expected?

The following code is ran in the test

$this->browse(function (Browser $browser) {
    $browser->visit('https://n98f62.csb.app/')
        ->waitFor('input[name=input]', 15)
        ->type('input', 'This clears the input')
        ->type('ant-input', 'This adds to the existing text')
        ->assertInputValue('input', 'This clears the input')
        ->assertInputValue('ant-input', 'This adds to the existing text');
});

The w3c webdriver spec states that calling POST /session/{session id}/element/{element id}/clear should clear the element. The Input component doesn't follow this standard.

What is actually happening?

The type() method calls clear() but only the html input element is cleared, the ant design Input is not.

Screenshot

failure-Tests_Browser_AntDesignClearElementTest_testExample-0

Environment Info
antd 4.23.0
React 18.2.0
System MacOS 12.5.1
Browser Firefox 105/Chrome 104

コントリビューターガイド