Vaadin TextField: как отключить подчеркивание?

Текстовое поле Vaadin имеет подчеркивание по умолчанию. Я хочу удалить его. Я использую его внутри поля со списком Vaadin.

В инструментах разработки я вижу, что причиной является div с атрибутом part="input-field". Установка его на display: none; работает в браузере. Кажется, я не могу настроить его с помощью кода. Я пробовал следующее:

`[part="input-field"] {
     display: none !important;
 }
 .vaadin-text-field-container [part="input-field"] {
     display: none !important;
 }`

person Nkosi Phillip    schedule 29.07.2019    source источник


Ответы (2)


Добавьте в проект надстройку Viritin (используйте последнюю версию) и настройте:

TextField field = new MTextField().withSpellCheckOff();

OR

вы можете использовать низкоуровневый API для настройки элемента html:

new HtmlElementPropertySetter(yourTextInputComponent).setProperty(
                "spellcheck", false);
person javan.rajpopat    schedule 30.07.2019
comment
Я обновил свой вопрос. А также я не могу добавить библиотеки в проект. Он должен быть максимально постным. - person Nkosi Phillip; 30.07.2019

Я решил это, добавив этот модуль в файл HTML. Я поместил это над первым тегом скрипта в файле.

<dom-module id="vaadin-text-field-module" theme-for="vaadin-text-field">
<template>
  <style>
    div::before, div::after {
      display: none;
    }
  </style>
</template>

:before is the underline before the input has a value and :after is the line after. Therefore this would disable both. [part="input-field"] disabled the input and the value was not seen after selection.

person Nkosi Phillip    schedule 30.07.2019